-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path20_zle.zsh
187 lines (160 loc) · 7.04 KB
/
20_zle.zsh
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# zsh command line editor
#
# CopyLeft - Calogero Lo Leggio <[email protected]>
# { zle options
# Choose word delimiter characters in line editor
WORDCHARS="*?_-.[]~/&;!#$%^(){}<>" # part of word in line editor
unsetopt beep # no beep me please
unsetopt overstrike # dont start le in overstrike mode
unsetopt single_line_zle # use multiline editor
setopt zle # use zsh le
# }
## { vi keybindings
#bindkey -v
#
#bindkey -M vicmd "^R" redo
#bindkey -M vicmd "u" undo
#bindkey -M vicmd "ga" what-cursor-position
## }
bindkey -e
# { standard
bindkey "$terminfo[kdch1]" delete-char # Delete
bindkey "\e[3~" delete-char # Delete
bindkey "$terminfo[khome]" beginning-of-line # Home
bindkey "\e[1~" beginning-of-line # Home
bindkey "^[[7~" beginning-of-line # Home (xterm)
bindkey "\eOH" beginning-of-line # Home (debian xterm)
bindkey "\e[7~" beginning-of-line # Home (rxvt)
bindkey "\e[H" beginning-of-line # Home (BSD)
bindkey "$terminfo[kend]" end-of-line # End
bindkey "\e[4~" end-of-line # End
bindkey "^[[8~" end-of-line # End (xterm)
bindkey "\eOF" end-of-line # End (debian xterm)
bindkey "\e[8~" end-of-line # End (rxvt)
bindkey "\e[F" end-of-line # End (BSD)
bindkey "$terminfo[kcuu1]" history-beginning-search-backward # Page Up
#bindkey "$terminfo[cuu1]" history-beginning-search-backward # Page Up
bindkey "^[[5~" history-beginning-search-backward # Page Up
bindkey "\e[5~" history-beginning-search-backward # Page Up
bindkey "$terminfo[kcud1]" history-beginning-search-forward # Page Down
#bindkey "$terminfo[cud1]" history-beginning-search-forward # Page Down
bindkey "\e[6~" history-beginning-search-forward # Page Down
bindkey "$terminfo[kich1]" overwrite-mode # Insert
bindkey "^[[2~" overwrite-mode # Insert
bindkey "\e[2~" overwrite-mode # Insert
bindkey "^[[A" up-history # UP arrow for back-history
bindkey "^[[B" down-history # DOWN arrow for fwd-history
#bindkey "^[[A" up-line-or-search # UP arrow for back-history-search
#bindkey "^[[B" down-line-or-search # DOWN arrow for fwd-history-search
#bindkey "^F" history-incremental-search-backward # ALT-R - history search
bindkey "^[r" history-incremental-search-backward # ALT-R - history search
bindkey " " magic-space # ' ' (Space)
# }
# { (u)rxvt compatibily
bindkey "\e[\304" backward-word # rxvt M-left
bindkey "\eOd" backward-word # rxvt C-left
bindkey "\e[\303" forward-word # rxvt M-right
bindkey "\eOc" forward-word # rxvt C-right
bindkey "\e[\301" beginning-of-line # rxvt M-up
bindkey "\e[\302" end-of-line # rxvt M-down
#bindkey '\e[3\376' delete-word # rxvt M-delete
# }
# { movement
bindkey "^[z" backward-word # ALT-Z
bindkey "^[x" forward-word # ALT-X
bindkey "^[c" vi-backward-word # ALT-C
bindkey "^[v" vi-forward-word # ALT-V
bindkey "^[a" vi-backward-kill-word # ALT-A
bindkey "^[s" delete-word # ALT-S
bindkey "^[q" backward-kill-line # ALT-Q
bindkey "^[w" kill-line # ALT-W
# }
# { menuselect
#bindkey -N menuselect
bindkey -M menuselect "$terminfo[kcuu1]" up-history
bindkey -M menuselect "$terminfo[kcud1]" down-history
bindkey -M menuselect "$terminfo[khome]" beginning-of-history
bindkey -M menuselect "$terminfo[kend]" end-of-history
bindkey -M menuselect "$terminfo[kcuu1]" beginning-of-line-hist
bindkey -M menuselect "$terminfo[kcud1]" end-of-line-hist
bindkey -M menuselect "^[[A" up-history
bindkey -M menuselect "^[[B" down-history
bindkey -M menuselect "^[[H" beginning-of-history
bindkey -M menuselect "^[[F" end-of-history
bindkey -M menuselect "^[[5~" beginning-of-line-hist
bindkey -M menuselect "^[[6~" end-of-line-hist
bindkey -M menuselect 'i' accept-and-menu-complete
#bindkey -M menuselect 'o' accept-and-infer-next-history
# }
# { misc
bindkey "$terminfo[kf1]" run-help # F1
bindkey "$terminfo[kf2]" which-command # F2
bindkey "^[OP" run-help # F1
bindkey "^[OQ" which-command # F2
bindkey "^Q" quote-line # CTRL-Q
#bindkey "^[e" undo # ALT-E
#bindkey "^[r" redo # ALT-R
bindkey "^[^[[A" up-case-word # ALT-UP
bindkey "^[^[[B" down-case-word # ALT-DOWN
bindkey "\eOa" vi-swap-case # CTRL-UP
bindkey "\eOb" vi-swap-case # CTRL-DOWN
bindkey "^t" run-with-sudo
bindkey "^[p" run-ps
bindkey "^v" edit_command_line
bindkey "^l" clear-term
bindkey "^e1" __jump_behind_first_word
bindkey -s "^r" "sudo -i\n"
bindkey -s "^[n" "netstat -ltupn\n"
#bindkey -s "^k" "cd ~L && make menuconfig\n"
#bindkey '\C-v' paste-xclip
# bindkey -s secret 'Oh no!'
#
# ^[^i == CTRL+ALT+i
# }
# { zle
run-with-sudo () {
# [[ -z $BUFFER ]] && zle up-history
[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER"
}
zle -N run-with-sudo
run-ps () {
zle -I
# ps axfww
ps x --forest -wwwA -o pid,user,cmd #-u $USER
# zle redisplay
}
zle -N run-ps
edit_command_line () {
# edit current line in $EDITOR
local tmpfile=${TMPPREFIX:-/tmp/zsh}ecl$$
print -R - "$PREBUFFER$BUFFER" >$tmpfile
exec </dev/tty
${VISUAL:-${EDITOR:-vi}} $tmpfile
zle kill-buffer
BUFFER=${"$(<$tmpfile)"/$PREBUFFER/}
CURSOR=$#BUFFER
command rm -f $tmpfile
zle redisplay
}
zle -N edit_command_line
function __jump_behind_first_word() {
local words
words=(${(z)BUFFER})
if (( ${#words} <= 1 )) ; then
CURSOR=${#BUFFER}
else
CURSOR=${#${words[1]}}
fi
}
zle -N __jump_behind_first_word
clear-term () {
zle -I
echo -ne '\033c'
}
zle -N clear-term
#paste-xclip() {
# BUFFER=$BUFFER"`xclip -o`"
# zle end-of-line
#}
#zle -N paste-xclip
# }