blob: 77f6efad37dbd0a2aa68a144c70e7413d26c8c02 [file] [log] [blame]
Skyler Greycecd9792022-07-27 14:38:47 +01001{ pkgs, config, fzf-tab, ... }: {
Skyler Turner62330c12022-03-04 22:10:16 +00002 programs.zsh = {
3 enable = true;
Skyler Grey0bd95942022-07-27 13:16:29 +01004 plugins = [ { name = "fzf-tab"; src = fzf-tab; } ];
Skyler Turner62330c12022-03-04 22:10:16 +00005 oh-my-zsh = {
6 enable = true;
7 plugins = [ "git" ];
8 theme = "crunch";
9 };
10 history = {
11 size = 10000;
12 path = "${config.xdg.dataHome}/zsh/history";
13 expireDuplicatesFirst = true;
14 extended = true;
15 };
16 initExtra = ''
Skyler Grey4c2e3592022-08-04 18:42:46 +010017 bindkey -v
Skyler Turner62330c12022-03-04 22:10:16 +000018 bindkey "\'\'$\{key[Up]}" up-line-or-search
19
20 command_not_found_handler ()
21 {
22 local p='/nix/store/ycclzpk99snlrk8sg9n4j8pm1927gavw-command-not-found/bin/command-not-found';
23 if [ -x "$p" ] && [ -f '/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite' ]; then
24 "$p" "$@" 2>&1 | sed -r 's/nix-shell -p (\S+)/nix shell nixpkgs#\1/g' 1>&2;
25 if [ $? = 126 ]; then
26 "$@";
27 else
28 return 127;
29 fi;
30 else
31 echo "$1: command not found" 1>&2;
32 return 127;
33 fi
34 }
Skyler Greye2f4ab92022-05-20 12:09:15 +010035
36 ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=243';
Skyler Grey87c0f2c2022-05-24 13:22:19 +010037 ZSH_HIGHLIGHT_STYLES[comment]='fg=248';
Skyler Greye45bfb82022-07-20 17:13:27 +010038
39 if [[ $SHLVL != "1" ]]; then
Skyler Greye93e7ec2022-07-20 22:51:35 +010040 export RPS1=$'%{\033[38;5;248m%}(%{$fg[red]%}L$SHLVL%{\033[38;5;248m%})%{\033[39m\033[49m%}'
Skyler Grey17ece8b2022-07-21 17:28:26 +010041 fi
42
43 function TRAPINT {
Skyler Greyf6109de2022-07-27 16:38:10 +010044 print -n "$fg_bold[red]^C$fg_no_bold[default]"
Skyler Grey17ece8b2022-07-21 17:28:26 +010045 return $(( 128 + $1 ))
46 }
Skyler Grey0bd95942022-07-27 13:16:29 +010047
48 # disable sort when completing `git checkout`
49 zstyle ':completion:*:git-checkout:*' sort false
50 # set descriptions format to enable group support
51 zstyle ':completion:*:descriptions' format '[%d]'
52 # set list-colors to enable filename colorizing
Skyler Greyf6109de2022-07-27 16:38:10 +010053 zstyle ':completion:*' list-colors ''${(s.:.)LS_COLORS}
Skyler Grey0bd95942022-07-27 13:16:29 +010054 # preview directory's content with exa when completing cd
55 zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 -l --color=always $realpath'
56 # switch group using `,` and `.`
57 zstyle ':fzf-tab:*' switch-group ',' '.'
58 enable-fzf-tab
Skyler Turner62330c12022-03-04 22:10:16 +000059 '';
60 enableSyntaxHighlighting = true;
61 enableAutosuggestions = true;
62 autocd = true;
63 dotDir = ".local/share/zsh";
64 };
Skyler Grey0bd95942022-07-27 13:16:29 +010065
66 home.packages = [
67 pkgs.fzf
68 ];
Skyler Greye2f4ab92022-05-20 12:09:15 +010069}