parseUrls done

This commit is contained in:
Ingolf Wagner 2021-02-20 19:56:32 +01:00
parent b16a30f957
commit cec4bb88c0
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B

View file

@ -24,6 +24,20 @@ let
# exec ${pkgs.appimage-run}/bin/appimage-run "$HOME/programs/Zettlr.AppImage" # exec ${pkgs.appimage-run}/bin/appimage-run "$HOME/programs/Zettlr.AppImage"
#''; #'';
parseUrl = pkgs.writeBashBin "parseUrl" ''
echo "$@" | \
${pkgs.jq}/bin/jq --raw-input --raw-output '
def parseURL: capture( "^((?<scheme>[^:/?#]+):)?(//(?<authority>(?<domain>[^/?#:]*)(:(?<port>[0-9]*))?))?((?<path>[^?#]*)\\?)?((?<query>([^#]*)))?(#(?<fragment>(.*)))?");
parseURL
'
'';
parseAndCopyLink = pkgs.writeBashBin "parseAndCopyLink" ''
${parseUrl}/bin/parseUrl "$@" | \
${pkgs.jq}/bin/jq --raw-output '"\(.scheme)://\(.domain)\(.path)"' | \
${pkgs.xclip}/bin/xclip
'';
zettlr = unstablePkgs.zettlr; zettlr = unstablePkgs.zettlr;
replaceLinks = pkgs.writers.writeBashBin "replace-link-with-content" # sh replaceLinks = pkgs.writers.writeBashBin "replace-link-with-content" # sh
@ -320,6 +334,8 @@ in {
memo memo
nixfmt nixfmt
dateutils dateutils
parseUrl
parseAndCopyLink
# needed for pycairo (in venv) # needed for pycairo (in venv)
pkgconf pkgconf