16de51404773a5e849c25a95e7612e212e7256a7

Author
Simon Rogers <webdev@centralblue.co.uk>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

feat(lib): allow setting custom completion dots sequence (#9424)

Closes #9424
Closes #9703

Co-authored-by: mortezadadgar <mortezadadgar97@gmail.com>
Co-authored-by: Marc Cornellà <hello@mcornella.com>

Diff

 1diff --git a/lib/completion.zsh b/lib/completion.zsh
 2index ebaab08564c47d87575ca1c71bdadfe0c13b15ec..2c5695487d474d0c1b82baaa22cad8e63bee7ab7 100644
 3--- a/lib/completion.zsh
 4+++ b/lib/completion.zsh
 5@@ -58,9 +58,12 @@ zstyle ':completion:*:*:*:users' ignored-patterns \
 6 # ... unless we really want to.
 7 zstyle '*' single-ignored show
 8 
 9-if [[ $COMPLETION_WAITING_DOTS = true ]]; then
10+if [[ ${COMPLETION_WAITING_DOTS:-false} != false ]]; then
11   expand-or-complete-with-dots() {
12-    print -Pn "%F{red}…%f"
13+    # use $COMPLETION_WAITING_DOTS either as toggle or as the sequence to show
14+    [[ $COMPLETION_WAITING_DOTS = true ]] && COMPLETION_WAITING_DOTS="%F{red}…%f"
15+    # turn off line wrapping and print prompt-expanded "dot" sequence
16+    printf '\e[?7l%s\e[?7h' "${(%)COMPLETION_WAITING_DOTS}"
17     zle expand-or-complete
18     zle redisplay
19   }
20diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template
21index 65d5ea65b2f165ed5302973a8dabbb41eaadd847..4a998c2fcfb1954002dc933b81436d3592a5a630 100644
22--- a/templates/zshrc.zsh-template
23+++ b/templates/zshrc.zsh-template
24@@ -45,8 +45,9 @@ ZSH_THEME="robbyrussell"
25 # ENABLE_CORRECTION="true"
26 
27 # Uncomment the following line to display red dots whilst waiting for completion.
28-# Caution: this setting can cause issues with multiline prompts (zsh 5.7.1 and newer seem to work)
29-# See https://github.com/ohmyzsh/ohmyzsh/issues/5765
30+# You can also set it to another string to have that shown instead of the default red dots.
31+# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
32+# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
33 # COMPLETION_WAITING_DOTS="true"
34 
35 # Uncomment the following line if you want to disable marking untracked files