File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,14 @@ _pinyin_completion() {
44
44
45
45
local cur=" ${COMP_WORDS[COMP_CWORD]} "
46
46
47
+ # Detect "~/"
48
+ local homeStart
49
+ if [ " ${cur: 0: 2} " = " ~/" ]; then
50
+ homeStart=true
51
+ else
52
+ homeStart=false
53
+ fi
54
+
47
55
# ignore empty
48
56
[ -z " $cur " ] && return
49
57
@@ -120,8 +128,14 @@ _pinyin_completion() {
120
128
done
121
129
COMPREPLY=( " ${unique_compreply[@]} " )
122
130
123
- # # fix space postfix
124
- # if ((${#COMPREPLY[@]} == 1)) && [[ ${COMPREPLY[0]} != */ ]]; then
125
- # compopt -o nospace 2>/dev/null
126
- # fi
131
+ if [[ " $homeStart " == true ]]; then
132
+ local home=" $HOME "
133
+ for i in " ${! COMPREPLY[@]} " ; do
134
+ case " ${COMPREPLY[$i]} " in
135
+ " $home " /* )
136
+ COMPREPLY[$i ]=" ~${COMPREPLY[$i]# " $home " } "
137
+ ;;
138
+ esac
139
+ done
140
+ fi
127
141
}
You can’t perform that action at this time.
0 commit comments