parseUrls done

feature/hass
Ingolf Wagner 2021-02-20 19:56:32 +01:00
parent b16a30f957
commit cec4bb88c0
Signed by: palo
GPG Key ID: 76BF5F1928B9618B
1 changed files with 16 additions and 0 deletions

View File

@ -24,6 +24,20 @@ let
# 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;
replaceLinks = pkgs.writers.writeBashBin "replace-link-with-content" # sh
@ -320,6 +334,8 @@ in {
memo
nixfmt
dateutils
parseUrl
parseAndCopyLink
# needed for pycairo (in venv)
pkgconf