Skyler Grey | a2dca22 | 2022-09-02 00:02:49 +0100 | [diff] [blame] | 1 | { |
| 2 | pkgs, |
| 3 | home, |
| 4 | username, |
Skyler Grey | 934f142 | 2022-09-04 11:50:04 +0100 | [diff] [blame] | 5 | fzf-tab, |
Skyler Grey | a2dca22 | 2022-09-02 00:02:49 +0100 | [diff] [blame] | 6 | ... |
| 7 | }: { |
| 8 | home = { |
| 9 | programs.zsh = { |
| 10 | enable = true; |
Skyler Grey | 934f142 | 2022-09-04 11:50:04 +0100 | [diff] [blame] | 11 | plugins = [ |
| 12 | { |
| 13 | name = "fzf-tab"; |
| 14 | src = fzf-tab; |
| 15 | } |
| 16 | ]; |
Skyler Grey | a2dca22 | 2022-09-02 00:02:49 +0100 | [diff] [blame] | 17 | 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 Grey | 934f142 | 2022-09-04 11:50:04 +0100 | [diff] [blame] | 70 | enable-fzf-tab |
Skyler Grey | a2dca22 | 2022-09-02 00:02:49 +0100 | [diff] [blame] | 71 | |
| 72 | alias compinit="true" |
Skyler Grey | 65e2369 | 2022-09-09 23:14:03 +0100 | [diff] [blame] | 73 | |
| 74 | source "${./zsh/completions/bun.zsh}" |
Skyler Grey | a2dca22 | 2022-09-02 00:02:49 +0100 | [diff] [blame] | 75 | ''; |
| 76 | enableSyntaxHighlighting = true; |
| 77 | enableAutosuggestions = true; |
| 78 | autocd = true; |
| 79 | dotDir = ".config/zsh"; |
| 80 | }; |
| 81 | |
Skyler Grey | 934f142 | 2022-09-04 11:50:04 +0100 | [diff] [blame] | 82 | home = { |
| 83 | shellAliases = { |
| 84 | ":q" = "exit"; |
| 85 | }; |
| 86 | packages = [pkgs.fzf]; |
Skyler Grey | a2dca22 | 2022-09-02 00:02:49 +0100 | [diff] [blame] | 87 | }; |
| 88 | }; |
| 89 | config.environment.persistence."/nix/persist".users.${username}.directories = [".local/share/zsh"]; |
| 90 | } |