Aloxaf / fzf-tab

Replace zsh's default completion selection menu with fzf!
MIT License
3.37k stars 97 forks source link

[BUG] Idk if its exactly a bug but there is a weird bug with color indicators #234

Closed yavko closed 2 years ago

yavko commented 3 years ago

Describe the bug

A clear and concise description of what the bug is.

I can make sure:

To Reproduce

Steps to reproduce the behavior:

  1. type cat in this example
  2. weird bug

Expected behavior

CleanShot 2021-10-16 at 21 02 28@2x

not having those things around the text

Screenshots

CleanShot 2021-10-16 at 21 03 12@2x

Environment:

Minimal zshrc

#### FIG ENV VARIABLES ####
# [ -s ~/.fig/shell/pre.sh ] && source ~/.fig/shell/pre.sh
#### END FIG ENV VARIABLES ####
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

# Start configuration added by Zim install {{{
#
# User configuration sourced by interactive shells
#

# -----------------
# Zsh configuration
# -----------------

#
# History
#

# Remove older command from the history if a duplicate is to be added.
setopt HIST_IGNORE_ALL_DUPS

#
# Input/output
#

# Set editor default keymap to emacs (`-e`) or vi (`-v`)
bindkey -e

# Prompt for spelling correction of commands.
#setopt CORRECT

# Customize spelling correction prompt.
#SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '

# Remove path separator from WORDCHARS.
WORDCHARS=${WORDCHARS//[\/]}

# --------------------
# Module configuration
# --------------------

#
# completion
#

# Set a custom path for the completion dump file.
# If none is provided, the default ${ZDOTDIR:-${HOME}}/.zcompdump is used.
#zstyle ':zim:completion' dumpfile "${ZDOTDIR:-${HOME}}/.zcompdump-${ZSH_VERSION}"

#
# git
#

# Set a custom prefix for the generated aliases. The default prefix is 'G'.
#zstyle ':zim:git' aliases-prefix 'g'

#
# input
#

# Append `../` to your input for each `.` you type after an initial `..`
#zstyle ':zim:input' double-dot-expand yes

#
# zsh-autosuggestions
#

#
# termtitle
#

function termtitlepwd() {
setopt LOCAL_OPTIONS EXTENDED_GLOB
local git_root current_dir separator
local -i dir_length
if zstyle -t ':zim:prompt-pwd' git-root && \
    git_root=$(command git rev-parse --show-toplevel 2>/dev/null); then
  current_dir="${PWD#${git_root:h}/}"
else
  current_dir=${(%):-%~}
fi
zstyle -s ':zim:prompt-pwd:separator' format 'separator' || separator='/'
zstyle -s ':zim:prompt-pwd:fish-style' dir-length 'dir_length' || dir_length=0
if [[ ${dir_length} -gt 0 || ${separator} != '/' ]]; then
  local current_dirs=("${(@s:/:)current_dir}")
  if (( dir_length > 0 && ${#current_dirs} > 2 )); then
    current_dirs[2,-2]=("${(@M)current_dirs[2,-2]##.#?(#c,${dir_length})}")
  fi
  separator=${(e)separator}
  current_dir="${(@pj:$separator:)current_dirs}"
fi
print -Rn ${current_dir}
}

# Set a custom terminal title format using prompt expansion escape sequences.
# See http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Simple-Prompt-Escapes
# If none is provided, the default '%n@%m: %~' is used.
zstyle ':zim:prompt-pwd:fish-style' dir-length 1
zstyle ':zim:termtitle' format 'zsh %~' 

# Customize the style that the suggestions are shown with.
# See https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md#suggestion-highlight-style
#ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=242'
#
# zsh-syntax-highlighting
#

# Set what highlighters will be used.
# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)

# Customize the main highlighter styles.
# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/main.md#how-to-tweak-it
#typeset -A ZSH_HIGHLIGHT_STYLES
#ZSH_HIGHLIGHT_STYLES[comment]='fg=242'

# ------------------
# Initialize modules
# ------------------

if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZDOTDIR:-${HOME}}/.zimrc ]]; then
  # Update static initialization script if it does not exist or it's outdated, before sourcing it
  source ${ZIM_HOME}/zimfw.zsh init -q
fi
source ${ZIM_HOME}/init.zsh

# ------------------------------
# Post-init module configuration
# ------------------------------

#
# zsh-history-substring-search
#

# Bind ^[[A/^[[B manually so up/down works both before and after zle-line-init
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down

# Bind up and down keys
zmodload -F zsh/terminfo +p:terminfo
if [[ -n ${terminfo[kcuu1]} && -n ${terminfo[kcud1]} ]]; then
  bindkey ${terminfo[kcuu1]} history-substring-search-up
  bindkey ${terminfo[kcud1]} history-substring-search-down
fi

bindkey '^P' history-substring-search-up
bindkey '^N' history-substring-search-down
bindkey -M vicmd 'k' history-substring-search-up
bindkey -M vicmd 'j' history-substring-search-down
# }}} End configuration added by Zim install

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
(( ! ${+functions[p10k]} )) || p10k finalize

test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"

#### Yavkos stuff ####

export VULTR_API_KEY='xxxx'
export PATH=~/.npm-global/bin:$PATH
export PATH=~/go/bin:$PATH
export PATH=~/yavkocli:$PATH
export PATH=~/.cargo/bin:$PATH
export PATH="/Users/yavor/.deno/bin:$PATH"
export PATH="/Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.2.0/Contents/Home/bin:$PATH"
export JAVA_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.2.0/Contents/Home
export PATH="/Applications/Xcode.app/Contents/Developer/usr/bin/safari-web-extension-converter:$PATH"
alias rm=trash
alias vscode="code-insiders ."
alias ls="exa --icons"
alias cat=bat
alias pip=pip3
export PATH="/Users/yavor/yavkocli/jadx-1.2.0.82-fork1/bin:$PATH"
export PATH="/usr/local/sbin:$PATH"
export PATH="/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Helpers:$PATH"
export VISUAL=nano
export EDITOR=nano
export Visual=nano
export Editor=nano
export visual=nano
export editor=nano
alias icat="kitty +kitten icat"

#### Yavkos stuff end ####

#### Yavkos Funcs ####
export ZSH_AUTOSUGGEST_STRATEGY=(history completion)
function show_hex() {
    perl -e 'foreach $a(@ARGV){print "\e[48:2::".join(":",unpack("C*",pack("H*",$a)))."m \e[49m "};print "\n"' "$@"
}

#### Yavkos Funcs ####

## fzf dracula ##
export FZF_DEFAULT_OPTS='--border rounded --ansi --color=fg:#f8f8f2,bg:#282a36,hl:#bd93f9 --color=fg+:#f8f8f2,bg+:#44475a,hl+:#bd93f9 --color=info:#ffb86c,prompt:#50fa7b,pointer:#ff79c6 --color=marker:#ff79c6,spinner:#ffb86c,header:#6272a4'
zstyle ':completion:*:git-checkout:*' sort false
zstyle ':completion:*:descriptions' format '[%d]'
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':fzf-tab:complete:*:*' fzf-preview 'less ${(Q)realpath}'
export LESSOPEN='|~/.lessfilter %s'
zstyle ':fzf-tab:*' switch-group ',' '.'
zstyle ':fzf-tab:*' fzf-command fzf
## fzf dracula end ##

#### FNM ENV VARIABLES ####
eval "$(fnm env)"
#### END FNM ENV VARIABLES ####

#### FIG ENV VARIABLES ####
# [ -s ~/.fig/fig.sh ] && source ~/.fig/fig.sh
#### END FIG ENV VARIABLES ####

# bpm #
 export PATH="${XDG_DATA_HOME:-$HOME/.local/share}/bpm/source/pkg/bin:$PATH"
 eval "$(bpm init zsh)"
# bpm #

[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh

zimrc:


# Start configuration added by Zim install {{{
# -------
# Modules
# -------

zmodule prompt-pwd
zmodule Aloxaf/fzf-tab

# Sets sane Zsh built-in environment options.
zmodule environment
# Provides handy git aliases and functions.
zmodule git
# Applies correct bindkeys for input events.
zmodule input
# Sets a custom terminal title.
zmodule termtitle
# Utility aliases and functions. Adds colour to ls, grep and less.
zmodule utility

zmodule romkatv/powerlevel10k
zmodule fzf
zmodule exa
zmodule zsh-users/zsh-completions
zmodule hadenlabs/zsh-kitty
#
# Prompt
#
# Exposes git repository status information to prompts.
zmodule git-info
# A heavily reduced, ASCII-only version of the Spaceship and Starship prompts.
zmodule asciiship

# Additional completion definitions for Zsh.
zmodule zsh-users/zsh-completions
# Enables and configures smart and extensive tab completion.
# completion must be sourced after zsh-users/zsh-completions
zmodule completion
# Fish-like autosuggestions for Zsh.
zmodule zsh-users/zsh-autosuggestions
# Fish-like syntax highlighting for Zsh.
# zsh-users/zsh-syntax-highlighting must be sourced after completion
zmodule zdharma/fast-syntax-highlighting
# Fish-like history search (up arrow) for Zsh.
# zsh-users/zsh-history-substring-search must be sourced after zsh-users/zsh-syntax-highlighting
zmodule zsh-users/zsh-history-substring-search
# }}} End configuration added by Zim install
Aloxaf commented 3 years ago

See #24

TLDR: add zstyle ':completion:*:descriptions' format '[%d]' to your zshrc

yavko commented 3 years ago

thx

yavko commented 3 years ago

@Aloxaf Didn't fix...

yavko commented 3 years ago

plus i already had that in my zshrc

Aloxaf commented 3 years ago

@yavko Put it to the end of zshrc, so that it won't be overridden by other plugins.

yavko commented 3 years ago

kk

yavko commented 3 years ago

@Aloxaf forgot to say its a very bottom and it still doesnt work!

Aloxaf commented 3 years ago

That's strange. Does it work in an interactive session?

yavko commented 3 years ago

nope

Aloxaf commented 3 years ago

Can you provide the output of zstyle -s ':completion:*:descriptions' format reply; echo $reply and cat $functions_source[_bat] ?

yavko commented 3 years ago

the first thing returns [%d] But the second thing never finishes it just stays blank and never does anything I have to kill it by my self.

brerx commented 3 years ago

the first thing returns [%d] But the second thing never finishes it just stays blank and never does anything I have to kill it by my self.

same output for me ☹️

Aloxaf commented 3 years ago

@yavko @brerx Does this bug only happen with cat or with every commands?

yavko commented 3 years ago

It happens with cat, and other commands as well Btw I made this bug report on my old pc it still happens on this fresh Manjaro linux install.

Aloxaf commented 3 years ago

@yavko Can you trigger the completion with C-x ., and then provide the log here?

yavko commented 3 years ago

How? image

Aloxaf commented 3 years ago

@yavko Enter cat, and then press Ctrl-x .

yavko commented 3 years ago

oh

yavko commented 3 years ago

image

yavko commented 3 years ago

using bat btw

brerx commented 3 years ago

Enter cat, and then press Ctrl-x .

It does not come back for me. Pressing Ctrl-c twice tells me that something has been written to a log file.

Content of that:

+fzf-tab-debug:9> : zsh 5.8
+fzf-tab-debug:10> zle .fzf-tab-orig-expand-or-complete-with-indicator














                                                                                                      

                                                                                                      

                                                                                                      

                                                                                                      

                                                                                                      

                                                                                                      

                                                                                                      

                                                                                                      

                                                                                                      

                                                                                                      

                                                                                                      

                                                                                                      

                                                                                                      

                                                                                                      

                                                                                                      
> 
                                                                                                      
⠋
0/0 (0)

> Brewfile
  Brewfile.lock.json
                                                                                                      

12/12 (0)


+fzf-tab-debug:11> unsetopt xtrace

For vim, the last parts seem to be hidden:

image
brerx commented 3 years ago

Might the unsetopt xtrace at the end mean something?

Aloxaf commented 3 years ago

@yavko There should be a log file after completion. Please upload it.

图片

@brerx It seems that fzf-tab is not the last plugin to wrap Tab (except zsh-autosuggestions, zsh-syntax-highlighting). Please provide your zshrc.

yavko commented 3 years ago

@yavko There should be a log file after completion. Please upload it.

图片

@brerx It seems that fzf-tab is not the last plugin to wrap Tab (except zsh-autosuggestions, zsh-syntax-highlighting). Please provide your zshrc.

ok

yavko commented 3 years ago

I don't see that, im pressing ctrl+x . no logs

brerx commented 3 years ago

I'm using prezto,

leaving out aliases and stuff, that's the most important parts of zshrc:

...
fpath=(~/.zsh/completion $fpath)
autoload -Uz compinit promptinit colors edit-command-line vcs-info
colors
compinit -i
promptinit
zle -N edit-command-line
...
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
...

and in the zpreztorc i have

...
# Set the Prezto modules to load (browse modules).
# The order matters.
zstyle ':prezto:load' pmodule \
  'environment' \
  'terminal' \
  'editor' \
  'history' \
  'directory' \
  'spectrum' \
  'utility' \
  'ssh' \
  'completion' \
  'homebrew' \
  'osx' \
  'ruby' \
  'rails' \
  'git' \
  'syntax-highlighting' \
  'history-substring-search' \
  'contrib-prompt' \
  'prompt' \
  'fzf-tab'
 ...

Now that you say so, I don't really know in what order these two are loaded, but maybe just the module order is important?

yavko commented 3 years ago

I use zimfw and have fzf-tab installed through aur and symlinked into the modules folder and have it loaded first in .zimrc so idk

yavko commented 3 years ago

Wait maybe i should switch the loading sequence

yavko commented 3 years ago

didnt work

nemotiger commented 2 years ago

I also have this problem, and I fixed it by removing this line: zstyle ':completion:*' format ' %F{yellow}-- %d --%f' Both prezto and zimfw have this setting.

yavko commented 2 years ago

Thanks! edit: I cant find it in my zshrc

nemotiger commented 2 years ago

I see that you are using Zim. It is line 37 of this file.

yavko commented 2 years ago

I commented it out nothing changes

nemotiger commented 2 years ago

You might need to remove some *.zwc files to make it work. Note that I have never used Zim and I'm just guessing. This type of issues are the main reason why I no longer use any configuration framework.

yavko commented 2 years ago

ok!

nemotiger commented 2 years ago

@Aloxaf Can my ad hoc solution help you fix the bug?

Aloxaf commented 2 years ago

@nemotiger Oh thanks, that helps a lot.

@yavko How about add zstyle ':completion:*:descriptions' format '[%d]' to the end of zshrc and then clear cache? It should be able to overwrite the framework's configuration.

yavko commented 2 years ago

How do I clear cache?

Aloxaf commented 2 years ago

@yavko just remove the *.zwc

yavko commented 2 years ago

k

yavko commented 2 years ago

Ok it still doesn't work i cleared all cache

Aloxaf commented 2 years ago

@yavko add these lines to your zshrc

zstyle -d ':completion:*' format
zstyle ':completion:*:descriptions' format '[%d]'
yavko commented 2 years ago

@yavko add these lines to your zshrc

zstyle -d ':completion:*' format
zstyle ':completion:*:descriptions' format '[%d]'

ok

yavko commented 2 years ago

IT WORKS! image

Aloxaf commented 2 years ago

Good, I will update the pinned issue.

yavko commented 2 years ago

Finally!