refactor: move git ignore alias to own script

nixos
Moritz Böhme 2023-08-26 11:37:18 +02:00
parent ec1a6acebc
commit 92e2e149bc
Signed by: moritz
GPG Key ID: 970C6E89EB0547A9
2 changed files with 31 additions and 20 deletions

View File

@ -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; [

View File

@ -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";
};