-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
129 lines (101 loc) · 3.31 KB
/
.zshrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#-------------------------------
# Options
#-------------------------------
# Quit if not interactive shell
[[ ! -o interactive ]] && return
# Source alias
[[ -r $HOME/.aliasrc ]] && source "$HOME/.aliasrc"
# History
HISTSIZE=2000
SAVEHIST=2000
export HISTFILE="$HOME/.histfile"
setopt HIST_IGNORE_ALL_DUPS
#-------------------------------
# Appearance
#-------------------------------
# Generate and source LS_COLORS
if [[ -r $HOME/.dir_colors ]]; then
eval $(dircolors -b "$HOME/.dir_colors")
elif [[ -r /etc/DIR_COLORS ]]; then
eval $(dircolors -b /etc/DIR_COLORS)
fi
# which colors
autoload -U colors && colors
# Prompt
[[ $SSH_CONNECTION ]] && local uath='%F{2}%n@%M%f '
if [[ -o login ]]; then
PS1='%n@%m %/ %# '
if command -v screen >/dev/null 2>&1 ; then
exec screen -S wsl-arch -RR
fi
else
PS1="%(1j.%F{3}.%F{7})◆%f ${uath}%F{4}%B%3~%b%f %(?.%F{7}.%F{1})%B>%b%f "
fi
# Insert new line before Prompt, except top line
precmd() {
precmd() {
echo
}
}
#-------------------------------
# Completion
#-------------------------------
# Enable menu select with isearch on single <Tab>
setopt MENU_COMPLETE
# CD by just typing path
setopt AUTO_CD
autoload -Uz compinit
# Module Pattern Standard Styles
zstyle ':completion:*' menu select interactive
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} "ma=40;93"
zstyle ':completion:*' file-sort access
zstyle ':completion:*' matcher-list '' \
'm:{[:lower:]\-}={[:upper:]\_}' \
'r:[^[:alpha:]]||[[:alpha:]]=** r:|=* m:{[:lower:]\-}={[:upper:]\_}' \
'r:|?=** m:{[:lower:]\-}={[:upper:]\_}'
# 'match-spec:left-pattern=trial-pattern'
# 'lr:lranchor|lrpat=tpat' 'lr:lanchor||ranchor=tpat'
# match-spec: Uppercase keeps cli input, lowercase changes to trial
zstyle ':completion:*' completer \
_expand _complete _ignored _correct _approximate
# ^ Control Functions
zmodload zsh/complist
compinit -d "$HOME/.zcompdump"
_comp_options+=(globdots)
# Quote URLs automatically when pasting on terminal
autoload -Uz bracketed-paste-magic
zle -N bracketed-paste bracketed-paste-magic
autoload -Uz url-quote-magic
zle -N self-insert url-quote-magic
#-------------------------------
# Keybindings
#-------------------------------
# Enable Vi mode
export KEYTIMEOUT=1
bindkey -v
# Menu Select
bindkey -M menuselect 'H' vi-backward-char # directional
bindkey -M menuselect 'J' vi-down-line-or-history
bindkey -M menuselect 'K' vi-up-line-or-history
bindkey -M menuselect 'L' vi-forward-char
bindkey -M menuselect '[' vi-backward-word # pages
bindkey -M menuselect ']' vi-forward-word
bindkey -M menuselect 'I' accept-and-menu-complete # include more files
bindkey -M menuselect 'U' undo # remove them
bindkey -M menuselect '^[' send-break # reset menu search
# Default -M main (emacs + viins)
bindkey '^?' backward-delete-char
bindkey '^W' backward-kill-word
bindkey '^U' backward-kill-line
bindkey '^K' kill-line
bindkey '^Y' yank
bindkey '\e[3~' vi-delete-char
# Search History
bindkey '^R' history-incremental-pattern-search-backward
bindkey '^F' history-incremental-pattern-search-forward
autoload -Uz edit-command-line
zle -N edit-command-line
bindkey -M vicmd '^V' edit-command-line
_exit-zsh() { exit }
zle -N _exit-zsh
bindkey '^D' _exit-zsh