Skyler Grey | cecd979 | 2022-07-27 14:38:47 +0100 | [diff] [blame] | 1 | { pkgs, config, fzf-tab, ... }: { |
Skyler Turner | 62330c1 | 2022-03-04 22:10:16 +0000 | [diff] [blame] | 2 | programs.zsh = { |
| 3 | enable = true; |
Skyler Grey | 0bd9594 | 2022-07-27 13:16:29 +0100 | [diff] [blame] | 4 | plugins = [ { name = "fzf-tab"; src = fzf-tab; } ]; |
Skyler Turner | 62330c1 | 2022-03-04 22:10:16 +0000 | [diff] [blame] | 5 | 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 Grey | 4c2e359 | 2022-08-04 18:42:46 +0100 | [diff] [blame] | 17 | bindkey -v |
Skyler Turner | 62330c1 | 2022-03-04 22:10:16 +0000 | [diff] [blame] | 18 | 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 Grey | e2f4ab9 | 2022-05-20 12:09:15 +0100 | [diff] [blame] | 35 | |
| 36 | ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=243'; |
Skyler Grey | 87c0f2c | 2022-05-24 13:22:19 +0100 | [diff] [blame] | 37 | ZSH_HIGHLIGHT_STYLES[comment]='fg=248'; |
Skyler Grey | e45bfb8 | 2022-07-20 17:13:27 +0100 | [diff] [blame] | 38 | |
| 39 | if [[ $SHLVL != "1" ]]; then |
Skyler Grey | e93e7ec | 2022-07-20 22:51:35 +0100 | [diff] [blame] | 40 | export RPS1=$'%{\033[38;5;248m%}(%{$fg[red]%}L$SHLVL%{\033[38;5;248m%})%{\033[39m\033[49m%}' |
Skyler Grey | 17ece8b | 2022-07-21 17:28:26 +0100 | [diff] [blame] | 41 | fi |
| 42 | |
| 43 | function TRAPINT { |
Skyler Grey | f6109de | 2022-07-27 16:38:10 +0100 | [diff] [blame] | 44 | print -n "$fg_bold[red]^C$fg_no_bold[default]" |
Skyler Grey | 17ece8b | 2022-07-21 17:28:26 +0100 | [diff] [blame] | 45 | return $(( 128 + $1 )) |
| 46 | } |
Skyler Grey | 0bd9594 | 2022-07-27 13:16:29 +0100 | [diff] [blame] | 47 | |
Skyler Grey | 112f3b7 | 2022-08-11 22:32:38 +0100 | [diff] [blame] | 48 | function tempd { |
| 49 | cd "$(mktemp -d)" |
| 50 | } |
| 51 | |
Skyler Grey | 0bd9594 | 2022-07-27 13:16:29 +0100 | [diff] [blame] | 52 | # disable sort when completing `git checkout` |
| 53 | zstyle ':completion:*:git-checkout:*' sort false |
| 54 | # set descriptions format to enable group support |
| 55 | zstyle ':completion:*:descriptions' format '[%d]' |
| 56 | # set list-colors to enable filename colorizing |
Skyler Grey | f6109de | 2022-07-27 16:38:10 +0100 | [diff] [blame] | 57 | zstyle ':completion:*' list-colors ''${(s.:.)LS_COLORS} |
Skyler Grey | 0bd9594 | 2022-07-27 13:16:29 +0100 | [diff] [blame] | 58 | # preview directory's content with exa when completing cd |
| 59 | zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 -l --color=always $realpath' |
| 60 | # switch group using `,` and `.` |
| 61 | zstyle ':fzf-tab:*' switch-group ',' '.' |
| 62 | enable-fzf-tab |
Skyler Grey | 81248f7 | 2022-08-11 00:16:06 +0100 | [diff] [blame] | 63 | |
| 64 | alias compinit="true" |
| 65 | source ${./zsh/completions}/* |
Skyler Turner | 62330c1 | 2022-03-04 22:10:16 +0000 | [diff] [blame] | 66 | ''; |
| 67 | enableSyntaxHighlighting = true; |
| 68 | enableAutosuggestions = true; |
| 69 | autocd = true; |
| 70 | dotDir = ".local/share/zsh"; |
| 71 | }; |
Skyler Grey | 0bd9594 | 2022-07-27 13:16:29 +0100 | [diff] [blame] | 72 | |
| 73 | home.packages = [ |
| 74 | pkgs.fzf |
| 75 | ]; |
Skyler Grey | e2f4ab9 | 2022-05-20 12:09:15 +0100 | [diff] [blame] | 76 | } |