aboutsummaryrefslogtreecommitdiffhomepage
path: root/zsh/zshrc
diff options
context:
space:
mode:
Diffstat (limited to 'zsh/zshrc')
-rw-r--r--zsh/zshrc83
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
5ZSH_THEME="archcraft"
6
7# typebrook/helper
8export SETTING_DIR=$HOME/helper
9source $SETTING_DIR/tools/init/load-settings.sh
10fpath=($SETTING_DIR/zsh $fpath)
11
12# Options
13setopt extended_glob
14setopt HIST_SAVE_NO_DUPS # Do not write a duplicate event to the history file.
15
16_comp_options+=(globdots) # With hidden files
17autoload -Uz compinit; compinit
18zstyle ':completion:*' menu select
19zstyle ':completion::complete:*' gain-privileges 1
20
21# PS1 with git status at right
22#autoload -U ps1; ps1
23alias ps1="vim $SETTING_DIR/zsh/ps1"
24autoload -Uz add-zsh-hook
25add-zsh-hook precmd precmd
26function 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
42typeset -g -A key
43
44key[Home]="${terminfo[khome]}"
45key[End]="${terminfo[kend]}"
46key[Insert]="${terminfo[kich1]}"
47key[Backspace]="${terminfo[kbs]}"
48key[Delete]="${terminfo[kdch1]}"
49key[Up]="${terminfo[kcuu1]}"
50key[Down]="${terminfo[kcud1]}"
51key[Left]="${terminfo[kcub1]}"
52key[Right]="${terminfo[kcuf1]}"
53key[PageUp]="${terminfo[kpp]}"
54key[PageDown]="${terminfo[knp]}"
55key[Shift-Tab]="${terminfo[kcbt]}"
56
57# setup key accordingly
58bindkey -- "\C-A" beginning-of-line
59bindkey -- "\C-E" end-of-line
60bindkey -- "${key[Insert]}" overwrite-mode
61bindkey -- "\C-D" delete-char
62bindkey -- "\C-H" backward-delete-char
63bindkey -- "\M-D" delete-word
64bindkey -- "\C-W" backward-delete-word
65bindkey -- "\C-P" up-line-or-history
66bindkey -- "\C-N" down-line-or-history
67bindkey -- "\C-B" backward-char
68bindkey -- "\C-F" forward-char
69bindkey -- "\M-B" backward-word
70bindkey -- "\M-F" forward-word
71bindkey -- "${key[PageUp]}" beginning-of-buffer-or-history
72bindkey -- "${key[PageDown]}" end-of-buffer-or-history
73bindkey -- "${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.
77if (( ${+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
83fi