From cec4bb88c0965800f44e9291c56d01febd936f08 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Sat, 20 Feb 2021 19:56:32 +0100 Subject: [PATCH] parseUrls done --- system/desktop/packages.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/system/desktop/packages.nix b/system/desktop/packages.nix index d4c7dff..e31bb2d 100644 --- a/system/desktop/packages.nix +++ b/system/desktop/packages.nix @@ -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( "^((?[^:/?#]+):)?(//(?(?[^/?#:]*)(:(?[0-9]*))?))?((?[^?#]*)\\?)?((?([^#]*)))?(#(?(.*)))?"); + 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