diff --git a/modules/fish.nix b/modules/fish.nix index 94035df..4464052 100644 --- a/modules/fish.nix +++ b/modules/fish.nix @@ -4,7 +4,6 @@ programs.fish = { enable = true; loginShellInit = '' - # Dodaje binarki Home Managera do PATH, jeśli jeszcze ich tam nie ma fish_add_path --move --prepend --path "$HOME/.nix-profile/bin" /nix/var/nix/profiles/default/bin /run/current-system/sw/bin ''; @@ -25,5 +24,52 @@ clear fastfetch --config ~/.config/fastfetch/startup.jsonc ''; + + functions = { + edit_dotfile = { + description = "Edit config file, reload, commit and push"; + body = '' + set -l config_dir "$HOME/.config/home-manager" + set -l file + + if test (count $argv) -gt 0 + set file $argv[1] + else + set file (fd . $config_dir --type f --exclude ".git" | fzf) + end + + if test -n "$file" + set -l md5_before (md5sum $file) + + nvim $file + + if test "$md5_before" != (md5sum $file) + echo "Changes made. Prepparing commit..." + + pushd $config_dir + + git add $file + + set -l rel_file (realpath --relative-to=$config_dir $file) + + set commit_msg "update: $rel_file" + git commit -m "$commit_msg" + git push + + home-manager switch -b backup + + popd + else + echo "No changes made" + end + end + + ''; + }; + + ls = { + body = "eza --long --icons --all --group-directories-first --git $argv"; + }; + }; }; }