refactor: move git ignore alias to own script

dev-docs
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 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 in
{ {
users.users.moritz = { users.users.moritz = {
@ -125,15 +153,16 @@ in
duf duf
entr entr
exa exa
f
gi
gparted gparted
neofetch neofetch
reptyr reptyr
ripgrep ripgrep
up up
vim
viu viu
wget wget
vim
f
]; ];
fonts.packages = with pkgs; [ fonts.packages = with pkgs; [

View File

@ -50,24 +50,6 @@ in
${exportedVariables} ${exportedVariables}
''; '';
functions = { 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 = ""; fish_greeting = "";
cheat = "cht.sh $argv | bat -p"; cheat = "cht.sh $argv | bat -p";
}; };