diff options
Diffstat (limited to 'zsh/zshrc')
| -rw-r--r-- | zsh/zshrc | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/zsh/zshrc b/zsh/zshrc new file mode 100644 index 0000000..d77e299 --- /dev/null +++ b/zsh/zshrc | |||
| @@ -0,0 +1,83 @@ | |||
| 1 | # Set name of the theme to load --- if set to "random", it will | ||
| 2 | # load a random theme each time oh-my-zsh is loaded, in which case, | ||
| 3 | # to know which specific one was loaded, run: echo $RANDOM_THEME | ||
| 4 | # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes | ||
| 5 | ZSH_THEME="archcraft" | ||
| 6 | |||
| 7 | # typebrook/helper | ||
| 8 | export SETTING_DIR=$HOME/helper | ||
| 9 | source $SETTING_DIR/tools/init/load-settings.sh | ||
| 10 | fpath=($SETTING_DIR/zsh $fpath) | ||
| 11 | |||
| 12 | # Options | ||
| 13 | setopt extended_glob | ||
| 14 | setopt HIST_SAVE_NO_DUPS # Do not write a duplicate event to the history file. | ||
| 15 | |||
| 16 | _comp_options+=(globdots) # With hidden files | ||
| 17 | autoload -Uz compinit; compinit | ||
| 18 | zstyle ':completion:*' menu select | ||
| 19 | zstyle ':completion::complete:*' gain-privileges 1 | ||
| 20 | |||
| 21 | # PS1 with git status at right | ||
| 22 | #autoload -U ps1; ps1 | ||
| 23 | alias ps1="vim $SETTING_DIR/zsh/ps1" | ||
| 24 | autoload -Uz add-zsh-hook | ||
| 25 | add-zsh-hook precmd precmd | ||
| 26 | function precmd() { | ||
| 27 | RIGHT=$(NUM=$($SETTING_DIR/tools/git/check-repos.sh -n); (( $NUM != 0 )) && echo $NUM) | ||
| 28 | PROMPT='%B%(?:%F{green}%m%f:%F{red}%m%f)%f %F{cyan} %c%f%b ' | ||
| 29 | RPROMPT="%B${RIGHT}%b" | ||
| 30 | } | ||
| 31 | |||
| 32 | # Directory Stack | ||
| 33 | #setopt AUTO_PUSHD # Push the current directory visited on the stack. | ||
| 34 | #setopt PUSHD_IGNORE_DUPS # Do not store duplicates in the stack. | ||
| 35 | #setopt PUSHD_SILENT # Do not print the directory stack after pushd or popd. | ||
| 36 | |||
| 37 | #alias d='dirs -v' | ||
| 38 | #for index ({1..9}) alias "$index"="cd +${index}"; unset index | ||
| 39 | |||
| 40 | # create a zkbd compatible hash; | ||
| 41 | # to add other keys to this hash, see: man 5 terminfo | ||
| 42 | typeset -g -A key | ||
| 43 | |||
| 44 | key[Home]="${terminfo[khome]}" | ||
| 45 | key[End]="${terminfo[kend]}" | ||
| 46 | key[Insert]="${terminfo[kich1]}" | ||
| 47 | key[Backspace]="${terminfo[kbs]}" | ||
| 48 | key[Delete]="${terminfo[kdch1]}" | ||
| 49 | key[Up]="${terminfo[kcuu1]}" | ||
| 50 | key[Down]="${terminfo[kcud1]}" | ||
| 51 | key[Left]="${terminfo[kcub1]}" | ||
| 52 | key[Right]="${terminfo[kcuf1]}" | ||
| 53 | key[PageUp]="${terminfo[kpp]}" | ||
| 54 | key[PageDown]="${terminfo[knp]}" | ||
| 55 | key[Shift-Tab]="${terminfo[kcbt]}" | ||
| 56 | |||
| 57 | # setup key accordingly | ||
| 58 | bindkey -- "\C-A" beginning-of-line | ||
| 59 | bindkey -- "\C-E" end-of-line | ||
| 60 | bindkey -- "${key[Insert]}" overwrite-mode | ||
| 61 | bindkey -- "\C-D" delete-char | ||
| 62 | bindkey -- "\C-H" backward-delete-char | ||
| 63 | bindkey -- "\M-D" delete-word | ||
| 64 | bindkey -- "\C-W" backward-delete-word | ||
| 65 | bindkey -- "\C-P" up-line-or-history | ||
| 66 | bindkey -- "\C-N" down-line-or-history | ||
| 67 | bindkey -- "\C-B" backward-char | ||
| 68 | bindkey -- "\C-F" forward-char | ||
| 69 | bindkey -- "\M-B" backward-word | ||
| 70 | bindkey -- "\M-F" forward-word | ||
| 71 | bindkey -- "${key[PageUp]}" beginning-of-buffer-or-history | ||
| 72 | bindkey -- "${key[PageDown]}" end-of-buffer-or-history | ||
| 73 | bindkey -- "${key[Shift-Tab]}" reverse-menu-complete | ||
| 74 | |||
| 75 | # Finally, make sure the terminal is in application mode, when zle is | ||
| 76 | # active. Only then are the values from $terminfo valid. | ||
| 77 | if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then | ||
| 78 | autoload -Uz add-zle-hook-widget | ||
| 79 | function zle_application_mode_start { echoti smkx } | ||
| 80 | function zle_application_mode_stop { echoti rmkx } | ||
| 81 | add-zle-hook-widget -Uz zle-line-init zle_application_mode_start | ||
| 82 | add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop | ||
| 83 | fi | ||