-
Notifications
You must be signed in to change notification settings - Fork 0
/
zle
97 lines (80 loc) · 1.99 KB
/
zle
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
#!/usr/bin/env bash
### ZLE
# Expand multiple dots
# https://github.com/parkercoates/dotfiles/blob/master/.zsh/expand-multiple-dots.zsh
function expand-multiple-dots() {
local MATCH
if [[ $LBUFFER =~ (^| )\.\.\.+ ]]; then
LBUFFER=$LBUFFER:fs%\.\.\.%../..%
fi
}
function expand-multiple-dots-then-expand-or-complete() {
zle expand-multiple-dots
zle expand-or-complete
}
function expand-multiple-dots-then-accept-line() {
zle expand-multiple-dots
zle accept-line
}
zle -N expand-multiple-dots
zle -N expand-multiple-dots-then-expand-or-complete
zle -N expand-multiple-dots-then-accept-line
bindkey '^I' expand-multiple-dots-then-expand-or-complete
bindkey '^M' expand-multiple-dots-then-accept-line
# end expand multiple dots
source ~/mouse.zsh
bindkey '^[m' zle-toggle-mouse
# zle-toggle-mouse
# put the cursor in a subshell $()
# using Ctrl-j
function _zle_subshell {
RBUFFER='$()'"$RBUFFER"
((CURSOR=CURSOR+2))
}
zle -N _zle_subshell
bindkey '^J' _zle_subshell
bindkey -s '^o' 'vif^M'
# list files
function _zle_ls_list() {
# list current files
# list=`ls --color -lhF --group-directories-first`
ls --color -lhF --group-directories-first
zle reset-prompt; zle redisplay
}
# toggles background shell
fancy-ctrl-z () {
if [[ $#BUFFER -eq 0 ]]; then
BUFFER="fg"
zle accept-line
else
zle push-input
zle clear-screen
fi
}
zle -N fancy-ctrl-z
bindkey '^Z' fancy-ctrl-z
# ctrl+<- | ctrl+->
bindkey "^[." forward-word
bindkey "^[," backward-word
# substitute for the default shell behavior of alt+.
# maps to alt+p
bindkey "^[p" insert-last-word
# Create a function.
insert-next-word() {
# Tell `insert-last-word` to go forward (1), instead of backward (-1).
zle insert-last-word -- 1
}
# Create a widget that calls the function above.
zle -N insert-next-word
# next word
# alt+n???
bindkey '^[n' insert-next-word
# zle_tree
function _zle_tree {
zle push-input
BUFFER="tree -L 1 -C"
zle accept-line
}
# widget
zle -N _zle_tree
bindkey '^t' _zle_tree