From 92e2e149bcf8b2c3d93344c5ecd516c41a0f2bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sat, 26 Aug 2023 11:37:18 +0200 Subject: [PATCH] refactor: move git ignore alias to own script --- modules/profiles/base.nix | 33 +++++++++++++++++++++++++++++++-- modules/programs/fish.nix | 18 ------------------ 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/modules/profiles/base.nix b/modules/profiles/base.nix index 102eb91..a5fa164 100644 --- a/modules/profiles/base.nix +++ b/modules/profiles/base.nix @@ -32,6 +32,34 @@ let complete -c f ''; }; + + gi = pkgs.writeFishApplication + { + name = "gi"; + runtimeInputs = with pkgs; [ fzf gum curl ]; + text = /* fish */ '' + set url https://www.gitignore.io/api + + if test (count $argv) -eq 0 + set choice ( curl -sL $url/list \ + | string split "," \ + | fzf -m \ + | string join "," ) + else + set choice (string join "," $argv[1..]) + end + + if gum confirm "Overwrite current .gitignore?" + curl -sL $url/$choice > .gitignore + else + curl -sL $url/$choice >> .gitignore + end + ''; + completions = /* fish */ '' + set args (curl -sL https://www.gitignore.io/api/list | string split ",") + complete -c gi -fa "$args" + ''; + }; in { users.users.moritz = { @@ -125,15 +153,16 @@ in duf entr exa + f + gi gparted neofetch reptyr ripgrep up + vim viu wget - vim - f ]; fonts.packages = with pkgs; [ diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index efc2dac..c9798c6 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -50,24 +50,6 @@ in ${exportedVariables} ''; functions = { - gi = '' - set url https://www.gitignore.io/api - - if test (count $argv) -eq 0 - set choice ( curl -sL $url/list \ - | string split "," \ - | ${getExe pkgs.fzf} -m \ - | string join "," ) - else - set choice (string join "," $argv[1..]) - end - - if ${getExe pkgs.gum} confirm "Overwrite current .gitignore?" - ${getExe pkgs.curl} -sL $url/$choice > .gitignore - else - ${getExe pkgs.curl} -sL $url/$choice >> .gitignore - end - ''; fish_greeting = ""; cheat = "cht.sh $argv | bat -p"; };