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 | 82e0070 | 2022-08-19 15:59:30 +0100 | [diff] [blame] | 17 | bindkey -v |
| 18 | bindkey "\'\'$\{key[Up]}" up-line-or-search |
Skyler Turner | 62330c1 | 2022-03-04 22:10:16 +0000 | [diff] [blame] | 19 | |
Skyler Grey | 82e0070 | 2022-08-19 15:59:30 +0100 | [diff] [blame] | 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 | |
Skyler Grey | 82e0070 | 2022-08-19 15:59:30 +0100 | [diff] [blame] | 36 | ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=243'; |
| 37 | ZSH_HIGHLIGHT_STYLES[comment]='fg=248'; |
Skyler Grey | e45bfb8 | 2022-07-20 17:13:27 +0100 | [diff] [blame] | 38 | |
Skyler Grey | 17ece8b | 2022-07-21 17:28:26 +0100 | [diff] [blame] | 39 | |
Skyler Grey | 82e0070 | 2022-08-19 15:59:30 +0100 | [diff] [blame] | 40 | function task_indicator { |
| 41 | if [ `task +READY +OVERDUE count 2> /dev/null` -gt "0" ] ; then |
| 42 | printf "%%{\\033[38;5;248m%%}(%%{$fg[magenta]%%}$(task +READY +OVERDUE count) OVERDUE%%{\033[38;5;248m%%})%%{$fg[default]%%}" |
| 43 | elif [ `task +READY +DUETODAY count 2> /dev/null` -gt "0" ] ; then |
| 44 | printf "%%{\\033[38;5;248m%%}(%%{$fg[red]%%}$(task +READY +DUETODAY count) DUE TODAY%%{\033[38;5;248m%%})%%{$fg[default]%%}" |
| 45 | elif [ `task +READY +DUETomorrow count 2> /dev/null` -gt "0" ] ; then |
| 46 | printf "%%{\\033[38;5;248m%%}(%%{$fg[yellow]%%}$(task +READY +DUETomorrow count) DUE TOMORROW%%{\033[38;5;248m%%})%%{$fg[default]%%}" |
| 47 | elif [ `task +READY urgency \> 10 count 2> /dev/null` -gt "0" ] ; then |
| 48 | printf "%%{\\033[38;5;248m%%}(%%{$fg[red]%%}$(task +READY urgency \\\> 10 count) URGENT%%{\033[38;5;248m%%})%%{$fg[default]%%}" |
| 49 | elif [ `task +READY count 2> /dev/null` -gt "0" ] ; then |
| 50 | printf "%%{\\033[38;5;248m%%}(%%{$fg[cyan]%%}$(task +READY count) TASKS%%{\033[38;5;248m%%})%%{$fg[default]%%}" |
| 51 | else |
| 52 | printf "%%{\\033[38;5;248m%%}(%%{$fg[green]%%}NO TASKS%%{\033[38;5;248m%%})%%{$fg[default]%%}" |
| 53 | fi |
| 54 | } |
Skyler Grey | 0bd9594 | 2022-07-27 13:16:29 +0100 | [diff] [blame] | 55 | |
Skyler Grey | 82e0070 | 2022-08-19 15:59:30 +0100 | [diff] [blame] | 56 | if [[ $SHLVL != "1" ]]; then |
| 57 | export RPS1=$'%{\033[38;5;248m%}(%{$fg[red]%}L$SHLVL%{\033[38;5;248m%})%{\033[39m\033[49m%} ' |
| 58 | fi |
| 59 | |
| 60 | RPS1+='$(task_indicator)' |
| 61 | |
| 62 | function TRAPINT { |
| 63 | print -n "$fg_bold[red]^C$fg_no_bold[default]" |
| 64 | return $(( 128 + $1 )) |
| 65 | } |
| 66 | |
| 67 | # function zle-line-init { |
| 68 | # if [[ -n $ZLE_LINE_ABORTED ]]; then |
| 69 | # MY_LINE_ABORTED="$ZLE_LINE_ABORTED" |
| 70 | # fi |
| 71 | |
| 72 | # if [[ -n $MY_LINE_ABORTED ]]; then |
| 73 | # local savebuf="$BUFFER" savecur="$CURSOR" |
| 74 | # BUFFER="$MY_LINE_ABORTED" |
| 75 | # CURSOR="$#BUFFER" |
| 76 | # zle split-undo |
| 77 | # BUFFER="$savebuf" CURSOR="$savecur" |
| 78 | # fi |
| 79 | # } |
| 80 | # zle -N zle-line-init |
| 81 | |
| 82 | function tempd { |
| 83 | cd "$(mktemp -d)" |
| 84 | } |
Skyler Grey | 112f3b7 | 2022-08-11 22:32:38 +0100 | [diff] [blame] | 85 | |
Skyler Grey | 0bd9594 | 2022-07-27 13:16:29 +0100 | [diff] [blame] | 86 | # disable sort when completing `git checkout` |
| 87 | zstyle ':completion:*:git-checkout:*' sort false |
| 88 | # set descriptions format to enable group support |
| 89 | zstyle ':completion:*:descriptions' format '[%d]' |
| 90 | # set list-colors to enable filename colorizing |
Skyler Grey | f6109de | 2022-07-27 16:38:10 +0100 | [diff] [blame] | 91 | zstyle ':completion:*' list-colors ''${(s.:.)LS_COLORS} |
Skyler Grey | 0bd9594 | 2022-07-27 13:16:29 +0100 | [diff] [blame] | 92 | # preview directory's content with exa when completing cd |
| 93 | zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 -l --color=always $realpath' |
| 94 | # switch group using `,` and `.` |
| 95 | zstyle ':fzf-tab:*' switch-group ',' '.' |
| 96 | enable-fzf-tab |
Skyler Grey | 81248f7 | 2022-08-11 00:16:06 +0100 | [diff] [blame] | 97 | |
| 98 | alias compinit="true" |
| 99 | source ${./zsh/completions}/* |
Skyler Grey | 82e0070 | 2022-08-19 15:59:30 +0100 | [diff] [blame] | 100 | ''; |
| 101 | enableSyntaxHighlighting = true; |
| 102 | enableAutosuggestions = true; |
| 103 | autocd = true; |
| 104 | dotDir = ".local/share/zsh"; |
| 105 | }; |
Skyler Grey | 0bd9594 | 2022-07-27 13:16:29 +0100 | [diff] [blame] | 106 | |
Skyler Grey | 82e0070 | 2022-08-19 15:59:30 +0100 | [diff] [blame] | 107 | home.packages = [ |
| 108 | pkgs.fzf |
| 109 | ]; |
| 110 | |
| 111 | home.shellAliases = { |
| 112 | ":q" = "exit"; |
| 113 | }; |
| 114 | } |