zsh.nix (2977B)
1 { config, pkgs, lib, ... }: 2 3 with lib; 4 5 let editor = "nvim"; 6 in 7 { 8 options.zsh = { 9 enable = mkEnableOption "Zsh"; 10 11 editor = mkOption { 12 type = types.str; 13 default = "nvim"; 14 example = "nano"; 15 description = "The default editor, which is what \$EDITOR will be set to"; 16 }; 17 18 aliases = mkOption { 19 type = types.attrsOf types.string; 20 default = {}; 21 example = { a = "echo hello"; }; 22 description = "Attrset of aliases"; 23 }; 24 }; 25 26 config = mkIf config.zsh.enable { 27 home.packages = [ pkgs.any-nix-shell ]; 28 programs.zsh = { 29 enable = true; 30 31 defaultKeymap = "viins"; 32 33 dotDir = ".config/zsh"; 34 35 # Fix slow startup time on laptop 36 # https://gist.github.com/ctechols/ca1035271ad134841284 37 completionInit = '' 38 autoload -Uz compinit 39 40 for dump in ''${ZDOTDIR}/.zcompdump(N.mh+24); do 41 compinit 42 done 43 44 compinit -C; 45 ''; 46 47 history = { 48 path = "/home/benjamin/.cache/zsh/history"; 49 }; 50 51 shellAliases = { 52 die = "shutdown now"; 53 ga = "git add"; 54 gc = "git commit"; 55 gd = "git diff"; 56 gp = "git push"; 57 grep = "grep --color=auto"; 58 gs = "git status"; 59 idris2 = "rlwrap idris2"; 60 l = "ls"; 61 la = "ls -la"; 62 ls = "ls --color=auto"; 63 ssh = "TERM=xterm-256color ssh"; 64 tmux = "tmux -2"; 65 v = config.zsh.editor; 66 }; 67 68 sessionVariables = { 69 EDITOR = config.zsh.editor; 70 NIX_PATH = "\$HOME/.nix-defexpr/channels\${NIX_PATH:+:}\$NIX_PATH"; 71 TERMINAL = "alacritty"; 72 }; 73 74 initExtra = '' 75 #. ~/.nix-profile/etc/profile.d/nix.sh 76 77 any-nix-shell zsh --info-right | source /dev/stdin 78 79 PATH=$PATH:$HOME/.local/scripts:$HOME/.local/bin 80 81 # From the fzf wiki 82 fd() { 83 local dir 84 dir=$(find ''${1:-.} -path '*/\.*' -prune \ 85 -o -type d -print 2> /dev/null | fzf-tmux -r +m) && 86 cd "$dir" 87 } 88 89 fh() { 90 eval $(history -n | fzf-tmux -r +m) 91 } 92 93 fmv() { 94 local dir 95 dir=$(find ''${2:-.} -path '*/\.*' -prune \ 96 -o -type d -print 2> /dev/null | fzf-tmux -r +m) && 97 mv $1 "$dir" 98 } 99 100 fcp() { 101 local dir 102 dir=$(find ''${2:-.} -path '*/\.*' -prune \ 103 -o -type d -print 2> /dev/null | fzf-tmux -r +m) && 104 cp $1 "$dir" 105 } 106 ''; 107 108 # plugins = [ 109 # { 110 # name = "zsh-nix-shell"; 111 # file = "nix-shell.plugin.zsh"; 112 # src = pkgs.fetchFromGitHub { 113 # owner = "chisui"; 114 # repo = "zsh-nix-shell"; 115 # rev = "v0.1.0"; 116 # sha256 = "0snhch9hfy83d4amkyxx33izvkhbwmindy0zjjk28hih1a9l2jmx"; 117 # }; 118 # } 119 # ]; 120 }; 121 }; 122 }