From a5612197423afa39005457fa14658a9788ea87f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sat, 20 Aug 2022 14:22:20 +0200 Subject: [PATCH] :sparkles: prettify gi script --- modules/programs/fish.nix | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index 4cb4bb2..d38f6d5 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -57,15 +57,23 @@ in ${exportedVariables} ''; functions = { - gi = '' + gi = with pkgs; '' set url https://www.gitignore.io/api - if test (count $argv) -ne 1 - set list (curl -sL $url/list | string split ",") - set choice (string split " " $list | fzf -m --preview "curl -sL $url/{}" | string join ",") + + if test (count $argv) -eq 0 + set choice ( curl -sL $url/list \ + | string split "," \ + | ${fzf}/bin/fzf -m \ + | string join "," ) else - set choice $argv[1] + set choice (string join "," $argv[1..]) + end + + if ${gum}/bin/gum confirm "Overwrite current .gitignore?" + ${curl}/bin/curl -sL $url/$choice > .gitignore + else + ${curl}/bin/curl -sL $url/$choice >> .gitignore end - curl -sL $url/$choice > .gitignore ''; fish_greeting = ""; cheat = "cht.sh $argv | bat -p";