diff options
Diffstat (limited to 'home-manager/fish/default.nix')
| -rw-r--r-- | home-manager/fish/default.nix | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/home-manager/fish/default.nix b/home-manager/fish/default.nix new file mode 100644 index 0000000..93fd234 --- /dev/null +++ b/home-manager/fish/default.nix @@ -0,0 +1,155 @@ +{ + programs ={ + fish = { + enable = true; + generateCompletions = true; + + interactiveShellInit = '' + set fish_greeting # Disable greeting + atuin init fish | source + + complete -c nixos -f + + 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" + + 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 = "fastfetch -c examples/7"; + }; + shellInitLast = '' + atuin init fish | source + eval "$(starship init fish)" + ''; + + 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 <path> || 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 <path> 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 --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 <python|nim|js|flake> [..]" + 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; + }; + }; +} |
