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() {
4444
4545 local cur=" ${COMP_WORDS[COMP_CWORD]} "
4646
47+ # Detect "~/"
48+ local homeStart
49+ if [ " ${cur: 0: 2} " = " ~/" ]; then
50+ homeStart=true
51+ else
52+ homeStart=false
53+ fi
54+
4755 # ignore empty
4856 [ -z " $cur " ] && return
4957
@@ -120,8 +128,14 @@ _pinyin_completion() {
120128 done
121129 COMPREPLY=( " ${unique_compreply[@]} " )
122130
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
127141}
You can’t perform that action at this time.
0 commit comments