{ lib, pkgs, variant, ... }: { programs.fish = { enable = true; loginShellInit = '' set -gx fish_greeting '' + (if variant == "allegro" then '' source ${pkgs.nix}/etc/profile.d/nix.fish if test $(tty) = /dev/tty2 nixGLIntel Hyprland end '' else ""); interactiveShellInit = '' set -gx fish_greeting set -x DIRENV_LOG_FORMAT "" bind \ef forward-word bind \eF accept-autosuggestion ''; functions = { # use "e" to open the text editor. if e job is paused, return to it e.body = '' jobs -c | grep $EDITOR \ || $EDITOR $argv \ && fg 2>/dev/null; commandline -f repaint ''; lfcd.body = '' set tmp (mktemp) # `command` is needed in case `lfcd` is aliased to `lf` command lf -last-dir-path=$tmp $argv if test -f "$tmp" set dir (cat $tmp) rm -f $tmp if test -d "$dir" if test "$dir" != (pwd) cd $dir end end end ''; fish_prompt.body = '' set -l last_pipestatus $pipestatus set -lx __fish_last_status $status # Export for __fish_print_pipestatus. set -l normal (set_color normal) set -q fish_color_status or set -g fish_color_status red # Color the prompt differently when we're root set -l color_cwd $fish_color_cwd set -l suffix '>' if functions -q fish_is_root_user; and fish_is_root_user if set -q fish_color_cwd_root set color_cwd $fish_color_cwd_root end set suffix '#' end # Write pipestatus # If the status was carried over (if no command is issued or if `set` leaves the status untouched), don't bold it. set -l bold_flag --bold set -q __fish_prompt_status_generation; or set -g __fish_prompt_status_generation $status_generation if test $__fish_prompt_status_generation = $status_generation set bold_flag end set __fish_prompt_status_generation $status_generation set -l status_color (set_color $fish_color_status) set -l statusb_color (set_color $bold_flag $fish_color_status) set -l prompt_status (__fish_print_pipestatus "[" "]" "|" "$status_color" "$statusb_color" $last_pipestatus) # direnv status TODO fix this if condition # if which direnv >/dev/null set -l direnv_status (direnv status | grep -q "Found RC path" && echo " direnv") # end # echo -n -s (prompt_login)' ' (set_color $color_cwd) (prompt_pwd) $normal (fish_vcs_prompt) \ echo -n -s (set_color $color_cwd) (prompt_pwd) $normal (fish_vcs_prompt) \ (set_color -i yellow) $direnv_status $normal " "$prompt_status " "$suffix " " ''; # run $argv when a file tracked by git is updated. gitentr.body = '' ${pkgs.git}/bin/git ls-tree -r HEAD --name-only | ${pkgs.entr}/bin/entr $argv ''; ffsum.body = '' ${pkgs.ffmpeg}/bin/ffmpeg -hide_banner -v error $argv[..-2] -i $argv[-1] -map 0:v -f md5 - ''; }; shellAliases = { ls = "ls -hN --color=auto --group-directories-first"; grep = "grep --color=auto"; diff = "diff --color=auto"; bt = "bluetuith"; hm = "home-manager"; hms = "home-manager switch"; dev = "nix develop -c fish"; gparted = "nix-shell -p pkgs.gparted --run 'sudo -E gparted'"; ns = "nix-shell"; nsp = "nix shell nixpkgs#"; f = "lfcd"; sxiv = "nsxiv"; del = "trash -rf"; rsyncp = "rsync --info=progress2 --no-inc-recursive"; ffmpeg = "ffmpeg -hide_banner"; ffprobe = "ffprobe -hide_banner"; co = "git checkout"; stash = "git stash"; popstash = "git stash pop"; pull = "git pull"; }; plugins = [ { name = "fish-lf-icons"; src = pkgs.fetchFromGitHub { owner = "joshmedeski"; repo = "fish-lf-icons"; rev = "d1c47b2088e0ffd95766b61d2455514274865b4f"; sha256 = "sha256-6po/PYvq4t0K8Jq5/t5hXPLn80iyl3Ymx2Whme/20kc="; }; } ]; }; }