update: modules/cli/fish.nix

This commit is contained in:
2026-02-23 16:35:34 +01:00
parent 7dee04d6e7
commit e55ae7e6c1

View File

@@ -3,105 +3,112 @@
{ {
programs.fish = { programs.fish = {
enable = true; enable = true;
loginShellInit = '' loginShellInit = # fish
fish_add_path --move --prepend --path "$HOME/.nix-profile/bin" /nix/var/nix/profiles/default/bin /run/current-system/sw/bin ''
''; fish_add_path --move --prepend --path "$HOME/.nix-profile/bin" /nix/var/nix/profiles/default/bin /run/current-system/sw/bin
'';
interactiveShellInit = '' interactiveShellInit = # fish
# no dum greeting ''
set fish_greeting "" # no dum greeting
set fish_greeting ""
set -gx GPG_TTY (tty) set -gx GPG_TTY (tty)
fish_vi_key_bindings fish_vi_key_bindings
fastfetch --config ~/.config/fastfetch/startup.jsonc fastfetch --config ~/.config/fastfetch/startup.jsonc
''; '';
functions = { functions = {
edit_dotfile = { edit_dotfile = {
description = "Edit config file, reload, commit and push"; description = "Edit config file, reload, commit and push";
body = '' body = # fish
set -l config_dir "$HOME/.config/home-manager" ''
set -l file set -l config_dir "$HOME/.config/home-manager"
set -l file
if test (count $argv) -gt 0 if test (count $argv) -gt 0
set file $argv[1] set file $argv[1]
else else
set file (fd . $config_dir --type f --exclude ".git" | fzf) set file (fd . $config_dir --type f --exclude ".git" | fzf)
end end
if test -n "$file" if test -n "$file"
set -l md5_before (md5sum $file) set -l md5_before (md5sum $file)
pushd $config_dir pushd $config_dir
nvim $file nvim $file
if test "$md5_before" != (md5sum $file) if test "$md5_before" != (md5sum $file)
echo "Changes made. Preparing commit..." echo "Changes made. Preparing commit..."
set -l rel_file (realpath --relative-to=$config_dir $file) set -l rel_file (realpath --relative-to=$config_dir $file)
if home-manager switch --flake "$config_dir#${ if home-manager switch --flake "$config_dir#${
if isNixOS then "nixos" else "arch" if isNixOS then "nixos" else "arch"
}" -b backup }" -b backup
git add -A git add -A
set commit_msg "update: $rel_file" set commit_msg "update: $rel_file"
git commit -m "$commit_msg" git commit -m "$commit_msg"
git push git push
end end
else else
echo "No changes made" echo "No changes made"
end end
popd popd
end end
''; '';
}; };
ls = { ls = {
body = "eza --long --icons --group-directories-first --git $argv"; body = # fish
"eza --long --icons --group-directories-first --git $argv";
}; };
lst = { lst = {
body = "eza --long --icons --color --git --tree $argv"; body = # fish
"eza --long --icons --color --git --tree $argv";
}; };
cp_mail = { cp_mail = {
body = "pandoc $argv -t html |wl-copy -t text/html"; body = # fish
"pandoc $argv -t html |wl-copy -t text/html";
}; };
update = { update = {
body = '' body = # fish
echo "===System update===" ''
echo "===System update==="
if not type -q yay if not type -q yay
echo "Yay not found Is this Arch? If yes, then please consider installing it!" echo "Yay not found Is this Arch? If yes, then please consider installing it!"
else else
yay yay
end end
if type -q pacman if type -q pacman
echo "===Remove orphans===" echo "===Remove orphans==="
set orphans (pacman -Qtdq) set orphans (pacman -Qtdq)
if test (count $orphans) -gt 0 if test (count $orphans) -gt 0
sudo pacman -Rns $orphans sudo pacman -Rns $orphans
end end
end end
if type -q flatpak if type -q flatpak
echo "===Flatpak update===" echo "===Flatpak update==="
flatpak update --noninteractive flatpak update --noninteractive
echo "===Flatpak remove unused===" echo "===Flatpak remove unused==="
flatpak uninstall --unused flatpak uninstall --unused
end end
if type -q nix-channel if type -q nix-channel
echo "===Nix update===" echo "===Nix update==="
nix-channel --update nix-channel --update
echo "===Nix garbage collection===" echo "===Nix garbage collection==="
home-manager expire-generations "-7 days" home-manager expire-generations "-7 days"
end end
''; '';
}; };
rm = { rm = {