forked from Mopip77/dotfile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzsh_enhance
67 lines (56 loc) · 1.45 KB
/
zsh_enhance
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
# zsh 的增强
# prompt abbr
prompt_dir() {
prompt_segment blue $CURRENT_FG '%2~'
}
#function zshaddhistory() {
#return 1
#}
# 退出nvim后光标变成block
bindkey -v
# Remove delay when entering normal mode (vi)
KEYTIMEOUT=5
# Change cursor shape for different vi modes.
function zle-keymap-select {
if [[ $KEYMAP == vicmd ]] || [[ $1 = 'block' ]]; then
echo -ne '\e[1 q'
elif [[ $KEYMAP == main ]] || [[ $KEYMAP == viins ]] || [[ $KEYMAP = '' ]] || [[ $1 = 'beam' ]]; then
echo -ne '\e[5 q'
fi
}
zle -N zle-keymap-select
# Start with beam shape cursor on zsh startup and after every command.
zle-line-init() { zle-keymap-select 'beam'}
# vi-mode home end 失效
bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line
# isAlias() {
#local FIRSTWORD EXPAND REALCMD
#FIRSTWORD="$1"
#EXPAND="$(whence -w $FIRSTWORD 2>/dev/null)"
#if [[ "${EXPAND}" == "${FIRSTWORD}: alias" ]]; then
#REALCMD="$(whence $FIRSTWORD)"
#if ! [[ "$REALCMD" =~ "^${FIRSTWORD} .*" ]]; then
#return 0
#fi
#fi
#return 1
#}
# 回显上条命令的alias实际command
#_-accept-line () {
#emulate -L zsh
#local -a WORDS FORMER
#WORDS=( ${(z)BUFFER} )
#FORMER=${WORDS}
#local -r FIRSTWORD=${WORDS[1]}
#if isAlias ${FIRSTWORD}; then
#WORDS[1]="$(whence ${FIRSTWORD})"
#BUFFER=${WORDS}
#fi
#print -s ${FORMER}
#zle .accept-line
#BUFFER="123"
#直接删除最后一行重复history
#gsed -i '$d' ~/.zsh_history
#}
#zle -N accept-line _-accept-line