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