Skip to content

Commit

Permalink
Improve Shift-Tab completion appearance
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonrichert committed May 29, 2021
1 parent 114c857 commit 7f44a6d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions completion/_autocomplete.all_matches
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ else
return
fi

local -a expl disp=( '' )
local -a expl
_description all-matches expl 'all matches'
compadd "$expl[@]" -d disp -C
compadd "$expl[@]" -C
5 changes: 3 additions & 2 deletions completion/_autocomplete.unambiguous
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ fi
local tag=unambiguous
_tags $tag
_tags && _requested $tag &&
_message -e unambiguous "common substring:%b %F{0}%K{11}$compstate[unambiguous]%f%k"
# Black text on bright yellow background
_message -e unambiguous \
$'%B%{\e[2m%}Shift-Tab:%b %{\e[2m%}insert %b%F{0}%K{11}'"$compstate[unambiguous]%f%k"
# \e[2m = faint; 0 = black; 11 = bright yellow
15 changes: 6 additions & 9 deletions module/.autocomplete.config
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ zstyle ':completion:*:options' matcher 'b:-=+'

zstyle ':completion:*' prefix-needed yes
zstyle ':completion:*:expand:*' accept-exact continue
zstyle ':completion:*:expand-alias:*' complete yes
zstyle ':completion:*' ignore-parents 'parent pwd directory'
zstyle ':completion:*:users' ignored-patterns '_*'
zstyle ':completion:*:widgets' ignored-patterns '.*' '*:*' '*orig-*'
Expand Down Expand Up @@ -94,15 +95,11 @@ _autocomplete.config.warnings-format() {
reply=( $'%{\e[01;02;39m%}'"No ${${:-$PREFIX$SUFFIX}:+matching }$d found."$'%{\e[0m%}' )
}

local kbd=$'%{\e[22;39m%}'
zstyle ':completion:*:unambiguous' format \
"$h1%d$hint (press ${kbd}Shift${hint}-${kbd}Tab$hint to insert)$end"
zstyle -e ':completion:*:all-matches' format _autocomplete.config.all-matches-format
_autocomplete.config.all-matches-format() {
local end=$'%{\e[0m%}' hint=$'%{\e[22;02;39m%}' kbd=$'%{\e[22;39m%}'
reply=( $'%{\e[01;02;39m%}'"%d$end" )
[[ $IPREFIX$PREFIX$SUFFIX$ISUFFIX == *${compstate[unambiguous]:#?}* ]] &&
reply[1]+=" ${hint}(press ${kbd}Shift${hint}-${kbd}Tab$hint to insert)$end"
zstyle ':completion:*:all-matches' format $'%B%{\e[2m%}Shift-Tab:%b %{\e[2m%}insert %d%b'
zstyle -e ':completion:*:all-matches' hidden _autocomplete.config.all-matches-hidden
_autocomplete.config.all-matches-hidden() {
reply=( all ); [[ $IPREFIX$PREFIX$SUFFIX$ISUFFIX == *${compstate[unambiguous]:#?}* ]] &&
reply=( yes )
}

zstyle ':completion:*:history-lines' format ''
Expand Down

0 comments on commit 7f44a6d

Please sign in to comment.