blob: ad18b7e7d1182092bd158a8da12a122d21addfe9 [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 = ''
17 bindkey "\'\'$\{key[Up]}" up-line-or-search
18
19 command_not_found_handler ()
20 {
21 local p='/nix/store/ycclzpk99snlrk8sg9n4j8pm1927gavw-command-not-found/bin/command-not-found';
22 if [ -x "$p" ] && [ -f '/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite' ]; then
23 "$p" "$@" 2>&1 | sed -r 's/nix-shell -p (\S+)/nix shell nixpkgs#\1/g' 1>&2;
24 if [ $? = 126 ]; then
25 "$@";
26 else
27 return 127;
28 fi;
29 else
30 echo "$1: command not found" 1>&2;
31 return 127;
32 fi
33 }
Skyler Greye2f4ab92022-05-20 12:09:15 +010034
35 ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=243';
Skyler Grey87c0f2c2022-05-24 13:22:19 +010036 ZSH_HIGHLIGHT_STYLES[comment]='fg=248';
Skyler Greye45bfb82022-07-20 17:13:27 +010037
38 if [[ $SHLVL != "1" ]]; then
Skyler Greye93e7ec2022-07-20 22:51:35 +010039 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 +010040 fi
41
42 function TRAPINT {
Skyler Greyf6109de2022-07-27 16:38:10 +010043 print -n "$fg_bold[red]^C$fg_no_bold[default]"
Skyler Grey17ece8b2022-07-21 17:28:26 +010044 return $(( 128 + $1 ))
45 }
Skyler Grey0bd95942022-07-27 13:16:29 +010046
47 # disable sort when completing `git checkout`
48 zstyle ':completion:*:git-checkout:*' sort false
49 # set descriptions format to enable group support
50 zstyle ':completion:*:descriptions' format '[%d]'
51 # set list-colors to enable filename colorizing
Skyler Greyf6109de2022-07-27 16:38:10 +010052 zstyle ':completion:*' list-colors ''${(s.:.)LS_COLORS}
Skyler Grey0bd95942022-07-27 13:16:29 +010053 # preview directory's content with exa when completing cd
54 zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 -l --color=always $realpath'
55 # switch group using `,` and `.`
56 zstyle ':fzf-tab:*' switch-group ',' '.'
57 enable-fzf-tab
Skyler Turner62330c12022-03-04 22:10:16 +000058 '';
59 enableSyntaxHighlighting = true;
60 enableAutosuggestions = true;
61 autocd = true;
62 dotDir = ".local/share/zsh";
63 };
Skyler Grey0bd95942022-07-27 13:16:29 +010064
65 home.packages = [
66 pkgs.fzf
67 ];
Skyler Greye2f4ab92022-05-20 12:09:15 +010068}