blob: 29b3afa45cccef422a1b225951cede96c3aa2571 [file] [log] [blame]
Skyler Greya2dca222022-09-02 00:02:49 +01001{
2 pkgs,
3 home,
4 username,
Skyler Grey934f1422022-09-04 11:50:04 +01005 fzf-tab,
Skyler Greya2dca222022-09-02 00:02:49 +01006 ...
7}: {
8 home = {
9 programs.zsh = {
10 enable = true;
Skyler Grey934f1422022-09-04 11:50:04 +010011 plugins = [
12 {
13 name = "fzf-tab";
14 src = fzf-tab;
15 }
16 ];
Skyler Greya2dca222022-09-02 00:02:49 +010017 oh-my-zsh = {
18 enable = true;
19 plugins = ["git"];
20 theme = "crunch";
21 };
22 history = {
23 size = 10000;
24 path = "${home.xdg.dataHome}/zsh/history";
25 expireDuplicatesFirst = true;
26 extended = true;
27 };
28 initExtra = ''
29 bindkey -v
30 bindkey "\'\'$\{key[Up]}" up-line-or-search
31
32 command_not_found_handler ()
33 {
34 local p='command-not-found';
35 if [ -x "$p" ] && [ -f '/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite' ]; then
36 "$p" "$@" 2>&1 | sed -r 's/nix-shell -p (\S+)/nix shell nixpkgs#\1/g' 1>&2;
37 if [ $? = 126 ]; then
38 "$@";
39 else
40 return 127;
41 fi;
42 else
43 echo "$1: command not found" 1>&2;
44 return 127;
45 fi
46 }
47
48 ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=243';
49 ZSH_HIGHLIGHT_STYLES[comment]='fg=248';
50
51
52 if [[ $SHLVL != "1" ]]; then
53 export RPS1=$'%{\033[38;5;248m%}(%{$fg[red]%}L$SHLVL%{\033[38;5;248m%})%{\033[39m\033[49m%} '
54 fi
55
56 function tempd {
57 cd "$(mktemp -d)"
58 }
59
60 # disable sort when completing `git checkout`
61 zstyle ':completion:*:git-checkout:*' sort false
62 # set descriptions format to enable group support
63 zstyle ':completion:*:descriptions' format '[%d]'
64 # set list-colors to enable filename colorizing
65 zstyle ':completion:*' list-colors ''${(s.:.)LS_COLORS}
66 # preview directory's content with exa when completing cd
67 zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 -l --color=always $realpath'
68 # switch group using `,` and `.`
69 zstyle ':fzf-tab:*' switch-group ',' '.'
Skyler Grey934f1422022-09-04 11:50:04 +010070 enable-fzf-tab
Skyler Greya2dca222022-09-02 00:02:49 +010071
72 alias compinit="true"
Skyler Grey65e23692022-09-09 23:14:03 +010073
74 source "${./zsh/completions/bun.zsh}"
Skyler Greya2dca222022-09-02 00:02:49 +010075 '';
76 enableSyntaxHighlighting = true;
77 enableAutosuggestions = true;
78 autocd = true;
79 dotDir = ".config/zsh";
80 };
81
Skyler Grey934f1422022-09-04 11:50:04 +010082 home = {
83 shellAliases = {
84 ":q" = "exit";
85 };
86 packages = [pkgs.fzf];
Skyler Greya2dca222022-09-02 00:02:49 +010087 };
88 };
89 config.environment.persistence."/nix/persist".users.${username}.directories = [".local/share/zsh"];
90}