{ programs ={ fish = { enable = true; generateCompletions = true; interactiveShellInit = '' set fish_greeting # disable greeting complete -c nixos -f # autocomplete for `nixos` command complete -c nixos \ -n "__fish_use_subcommand" \ -a "update" \ -d "Update system using nh" complete -c nixos \ -n "__fish_use_subcommand" \ -a "upgrade" \ -d "Upgrade system using nh" complete -c nixos \ -n "__fish_use_subcommand" \ -a "config" \ -d "Edit nix config file" complete -c nixos \ -n "__fish_use_subcommand" \ -a "clean" \ -d "Clean nix store" # make `nixos config` autocomplete based on $HOME/.nix complete -c nixos \ -n "__fish_seen_subcommand_from config" \ -a "(__fish_nixos_config_files)" \ -f ''; shellAliases = { ls = "eza --icons=always --color=always"; ll = "eza -a --long --icons=always --color=always --no-time"; lt = "eza -a --long --tree --icons=always --color=always --no-time"; cat = "bat"; grep = "grep --color=auto"; mv = "mv -i"; cp = "cp -i"; rm = "rm -i"; fetch = "nix run nixpkgs#pfetch"; }; shellInitLast = ''''; functions = { __fish_nixos_config_files = '' # Only show directories and files inside ~/.nix set base "$HOME/.nix" for f in (command find $base \ \( -type d -name .git -prune \) -o \ -type f -print 2>/dev/null) if string match -rq '\.(otf|ttf|svg|png|jpg)$' -- $f continue end echo $f end | while read -l f set rel (string replace -r "^$base/" "" $f) echo $rel end ''; nixos = '' set defaultResponse "Usage: nixos update | up || nixos upgrade || nixos config || nixos clean" if test (count $argv) -lt 1 echo defaultResponse return 1 end switch $argv[1] case update up if test (count $argv) -gt 1 echo "Error: 'nixos update' takes no additional arguments." return 1 end nh os switch $HOME/.nix case upgrade if test (count $argv) -gt 1 echo "Error: 'nixos upgrade' takes no additional arguments." return 1 end nh os switch $HOME/.nix -u --ask case config if test (count $argv) -lt 2 echo "Error: 'nixos config' requires a argument (relative to $HOME/.nix)" return 1 end hx ~/.nix/$argv[2] case clean if test (count $argv) -gt 1 echo "Error: 'nixos clean' takes no additional arguments." return 1 end nh clean all --verbose case '*' echo defaultResponse return 1 end ''; nix = '' if test $argv[1] = develop set -l flake if test (count $argv) -lt 2 echo "Usage: nix develop [..]" return 1 end switch $argv[2] case python set flake $HOME/.nix#python set argv $argv[3..-1] case js set flake $HOME/.nix#js set argv $argv[3..-1] case python set flake $HOME/.nix#nim set argv $argv[3..-1] case '*' set flake $argv[2] set argv $argv[3..-1] end command nix develop $flake -c fish else command nix $argv end ''; }; }; starship = { enable = true; }; atuin = { enable = true; enableFishIntegration = true; }; }; }