Code Monkey home page Code Monkey logo

Comments (12)

sainnhe avatar sainnhe commented on June 7, 2024 1

Of course I want to fix this bug, but I don't know how to fix a bug that I can't reproduce.

I don't have a Mac at this moment, but I plan to buy one next month, so I will try to fix it later.

If you have time, you can try to debug the shell scripts and see if it's possible to fix it by yourself. PR is welcome.

from tmux-fzf.

sainnhe avatar sainnhe commented on June 7, 2024 1

It's caused by BSD sed on mac (which is incompatible with GNU sed on linux).

Should be fixed now.

from tmux-fzf.

sainnhe avatar sainnhe commented on June 7, 2024

I can't reproduce this, both will read $FZF_DEFAULT_OPTS on my machine, not sure if it's caused by your shell.

You can try to add $FZF_DEFAULT_OPTS to ~/.tmux.conf

from tmux-fzf.

ngocphamm avatar ngocphamm commented on June 7, 2024

@sainnhe That's weird 🤔

This is my .zshrc. I have commented out all the plugins that make use of fzf (fzf-tab, enhancd, and zoxide) but it still happens

##### DEBUG OPTIONS
# zmodload zsh/zprof
# setopt SOURCE_TRACE

##### Helper functions
# Returns whether the given command is executable or aliased.
# https://superuser.com/questions/351889/what-is-the-unix-command-to-find-out-what-executable-file-corresponds-to-a-given/351995#351995
_has() {
  return $( whence $1 >/dev/null )
}

# [[ $TMUX = '' ]] && export TERM='xterm-256color'

##### Environment Variables
# Making those paths unique
typeset -gU cdpath fpath mailpath path

# Set the list of directories that Zsh searches for programs.
path=(
  /usr/local/{bin,sbin}
  $path
  $HOME/.composer/vendor/bin
)

setopt promptsubst
autoload -Uz promptinit && promptinit

# A few Prezto settings for later loading of Prezto modules
zstyle ':prezto:*:*' color 'yes'
zstyle ':prezto:module:editor' key-bindings 'emacs'

##### Zinit (formerly Zplugin) - https://github.com/zdharma/zinit
source '/Users/ngoc/.zinit/bin/zinit.zsh'

zinit light-mode for \
  zinit-zsh/z-a-submods \
  zinit-zsh/z-a-bin-gem-node \
  zinit-zsh/z-a-patch-dl \
  mafredri/zsh-async

# Loading Prezto modules. Load sequence MATTERS.
zinit ice svn; zinit snippet PZT::modules/environment
zinit ice svn; zinit snippet PZT::modules/helper
zinit ice svn; zinit snippet PZT::modules/git
zinit ice svn; zinit snippet PZT::modules/editor
# zinit light Aloxaf/fzf-tab
zinit light _local/ngoc-prompt

zinit ice svn wait"0a" lucid; zinit snippet PZT::modules/utility
zinit ice svn wait"0a" lucid; zinit snippet PZT::modules/history
zinit ice svn wait"0a" lucid; zinit snippet PZT::modules/osx
# zinit ice svn wait"0a" lucid; zinit snippet PZT::modules/ruby
zinit ice wait"0a" lucid; zinit light djui/alias-tips
zinit ice wait"0a" lucid from"gh-r" as"program"; zinit light achannarasappa/ticker
zinit ice wait"0a" lucid from"gh-r" as"program"; zinit light tarkah/tickrs

# Loading my own custom things
zinit ice wait"0b" lucid; zinit light _local/custom

# This MUST go after FZF completion, which is in _local/custom
# zinit ice wait"0b" lucid pick"init.sh"; zinit light b4b4r07/enhancd

# Zoxide - very much like (better) fasd
# zinit ice wait"0b" lucid from"gh-r" as"program" \
#   mv"zoxide*/zoxide -> zoxide" \
#   atclone"./zoxide init --no-aliases zsh > init.zsh" \
#   atpull"%atclone" src"init.zsh" nocompile'!'
# zinit light ajeetdsouza/zoxide

zinit wait"0c" lucid light-mode for \
  atinit"zicompinit; zicdreplay" zdharma/fast-syntax-highlighting \
  atload"_zsh_autosuggest_start" zsh-users/zsh-autosuggestions \
  blockf atpull"zinit creinstall -q ." zsh-users/zsh-completions

The _local/custom plugin loads another zsh config file of my own, to mostly define aliases, and env variables, and configurations for some program, and this is the only part related to fzf

# FZF. Fuzzy file finder for shell & vim
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh

if _has fzf && _has rg && _has fd; then
  # rg, or fd commands need to be installed separately
  # https://github.com/sharkdp/fd
  # https://github.com/BurntSushi/ripgrep

  export FZF_DEFAULT_COMMAND='fd --type f --hidden --color never --exclude ".git"'
  # export FZF_DEFAULT_COMMAND='rg --color never --files --hidden --glob "!.git" 2> /dev/null'
  export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
  export FZF_ALT_C_COMMAND='fd --type d --hidden --color never ""'

  # So do cd ~~, nv conf~~, or ssh ~~, etc.
  export FZF_COMPLETION_TRIGGER='~~'

  # Or trigger completion with Ctrl-T
  # export FZF_COMPLETION_TRIGGER=''
  # bindkey '^T' fzf-completion
  # bindkey '^I' $fzf_default_completion

  # Some options:
  # --reverse
  # --border
  export FZF_DEFAULT_OPTS='--height 40% --reverse'
  export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden:wrap --bind 'ctrl-alt-p:toggle-preview'"

  # https://github.com/fnune/base16-fzf/blob/master/bash/base16-ocean.config
  _gen_fzf_default_opts() {
    local color00='#2b303b'
    local color01='#343d46'
    local color02='#4f5b66'
    local color03='#65737e'
    local color04='#a7adba'
    local color05='#c0c5ce'
    local color06='#dfe1e8'
    local color07='#eff1f5'
    local color08='#bf616a'
    local color09='#d08770'
    local color0A='#ebcb8b'
    local color0B='#a3be8c'
    local color0C='#96b5b4'
    local color0D='#8fa1b3'
    local color0E='#b48ead'
    local color0F='#ab7967'

      export FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS"\
" --color=bg+:$color01,bg:$color00,spinner:$color0C,hl:$color0D"\
" --color=fg:$color04,header:$color0D,info:$color0A,pointer:$color0C"\
" --color=marker:$color0C,fg+:$color06,prompt:$color0A,hl+:$color0D"
    }

    _gen_fzf_default_opts

  # Use tmux popup, if it's available (tmux 3.2 exposes "$TERM_PROGRAM")
  if [ "$TERM_PROGRAM" = "tmux" ] && [ ! -z "$TMUX" ]; then
    export FZF_TMUX=1
    export FZF_TMUX_OPTS='-p 40%'
  fi

  # For ZSH command fuzzy completion. COMMAND [DIRECTORY/][FUZZY_PATTERN]**<TAB>
  # Use fd as it has option to filter by type, so we can get folders only
  _fzf_compgen_path() {
    fd --hidden --follow --exclude ".git" . "$1"
  }

  _fzf_compgen_dir() {
    fd --type d --hidden --follow --exclude ".git" . "$1"
  }
fi

from tmux-fzf.

ngocphamm avatar ngocphamm commented on June 7, 2024

So if I added TMUX_FZF_OPTIONS="-p -w 62% -h 38% -m --reverse" to .tmux.conf then it respects my --reverse option now. However, the fzf colors still don't stick after the first prompt (same as in the gif I shared in my first post).

from tmux-fzf.

sainnhe avatar sainnhe commented on June 7, 2024

You can try to add $FZF_DEFAULT_OPTS to ~/.tmux.conf

Did you tried this?


I can't reproduce it, could you provide minimal zshrc and .tmux.conf that can reproduce this bug?

from tmux-fzf.

ngocphamm avatar ngocphamm commented on June 7, 2024

You can try to add $FZF_DEFAULT_OPTS to ~/.tmux.conf

Did you tried this?

I'm really sorry. I just didn't know how to put that shell environment variable into the .tmux.conf file.

I can't reproduce it, could you provide minimal zshrc and .tmux.conf that can reproduce this bug?

I can reproduce it with this very minimal config

.zshrc ([ -f ~/.fzf.zsh ] && source ~/.fzf.zsh is the script generated by fzf with $(brew --prefix)/opt/fzf/install per installation instructions from fzf)

##### Helper functions
# Returns whether the given command is executable or aliased.
# https://superuser.com/questions/351889/what-is-the-unix-command-to-find-out-what-executable-file-corresponds-to-a-given/351995#351995
_has() {
  return $( whence $1 >/dev/null )
}

# [[ $TMUX = '' ]] && export TERM='xterm-256color'

##### Environment Variables
# Making those paths unique
typeset -gU cdpath fpath mailpath path

# Set the list of directories that Zsh searches for programs.
path=(
  /usr/local/{bin,sbin}
  $path
  $HOME/.composer/vendor/bin
)

setopt promptsubst
autoload -Uz promptinit && promptinit

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

  export FZF_DEFAULT_COMMAND='fd --type f --hidden --color never --exclude ".git"'
  # export FZF_DEFAULT_COMMAND='rg --color never --files --hidden --glob "!.git" 2> /dev/null'
  export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
  export FZF_ALT_C_COMMAND='fd --type d --hidden --color never ""'

  # So do cd ~~, nv conf~~, or ssh ~~, etc.
  export FZF_COMPLETION_TRIGGER='~~'

  # Or trigger completion with Ctrl-T
  # export FZF_COMPLETION_TRIGGER=''
  # bindkey '^T' fzf-completion
  # bindkey '^I' $fzf_default_completion

  # Some options:
  # --reverse
  # --border
  export FZF_DEFAULT_OPTS='--height 40% --reverse'
  export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden:wrap --bind 'ctrl-alt-p:toggle-preview'"

  # https://github.com/fnune/base16-fzf/blob/master/bash/base16-ocean.config
  _gen_fzf_default_opts() {
    local color00='#2b303b'
    local color01='#343d46'
    local color02='#4f5b66'
    local color03='#65737e'
    local color04='#a7adba'
    local color05='#c0c5ce'
    local color06='#dfe1e8'
    local color07='#eff1f5'
    local color08='#bf616a'
    local color09='#d08770'
    local color0A='#ebcb8b'
    local color0B='#a3be8c'
    local color0C='#96b5b4'
    local color0D='#8fa1b3'
    local color0E='#b48ead'
    local color0F='#ab7967'

      export FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS"\
" --color=bg+:$color01,bg:$color00,spinner:$color0C,hl:$color0D"\
" --color=fg:$color04,header:$color0D,info:$color0A,pointer:$color0C"\
" --color=marker:$color0C,fg+:$color06,prompt:$color0A,hl+:$color0D"
    }

    _gen_fzf_default_opts

  # Use tmux popup, if it's available (tmux 3.2 exposes "$TERM_PROGRAM")
  if [ "$TERM_PROGRAM" = "tmux" ] && [ ! -z "$TMUX" ]; then
    export FZF_TMUX=1
    export FZF_TMUX_OPTS='-p 40%'
  fi

  # For ZSH command fuzzy completion. COMMAND [DIRECTORY/][FUZZY_PATTERN]**<TAB>
  # Use fd as it has option to filter by type, so we can get folders only
  _fzf_compgen_path() {
    fd --hidden --follow --exclude ".git" . "$1"
  }

  _fzf_compgen_dir() {
    fd --type d --hidden --follow --exclude ".git" . "$1"
  }

.tmux.conf

set -sg escape-time 10

set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'sainnhe/tmux-fzf'
TMUX_FZF_LAUNCH_KEY="C-f"
# TMUX_FZF_OPTIONS="-p -w 62% -h 38% -m --reverse"
TMUX_FZF_ORDER="pane|window|session|command|keybinding"

run '~/.tmux/plugins/tpm/tpm'

This is on

  • macOS 10.15.7 (Catalina)
  • iTerm2 latest version (also happen in Alacritty)
  • Tmux 3.2a (installed with brew)

Please let me know if you need any more information
CleanShot 2021-07-18 at 10 22 17

from tmux-fzf.

sainnhe avatar sainnhe commented on June 7, 2024

Peek 2021-07-19 09-22

I still can't reproduce it using your config, there must be something wrong in your dotfiles. If you have a dotfiles repo, maybe you can try git grep FZF_DEFAULT_OPTS to find where does it change.


I'm really sorry. I just didn't know how to put that shell environment variable into the .tmux.conf file.

This line is exactly setting a shell environment variable:

TMUX_FZF_ORDER="pane|window|session|command|keybinding"

from tmux-fzf.

ngocphamm avatar ngocphamm commented on June 7, 2024

I tried a rg --hidden FZF_DEFAULT_OPTS search and this is the result

https://gist.github.com/ngocphamm/b58e33743abf44c80ef0fa47c4876584

The first "file" is the counts only. The second "file" contains all the matches, except those in DATA, Downloads, Documents, or Library folders that I don't think would matter.

The only thing I could think of from the result is from the file .zinit/plugins/b4b4r07---enhancd/src/completion.zsh. However, my minimal config obviously doesn't have enhancd (or even zinit) enabled. And again, inside a shell spun up with that minimal config, just before firing tmux-fzf, this is the value for FZF_DEFAULT_OPTS

ngoc@NMBP161 ~ %  echo $FZF_DEFAULT_OPTS
--height 40% --reverse --color=bg+:#343d46,bg:#2b303b,spinner:#96b5b4,hl:#8fa1b3 --color=fg:#a7adba,header:#8fa1b3,info:#ebcb8b,pointer:#96b5b4 --color=marker:#96b5b4,fg+:#dfe1e8,prompt:#ebcb8b,hl+:#8fa1b3

Sorry I didn't know about that shell environment variable stuff. I was always thinking it's "tmux variables". I will try that too, but still really want to figure out why this is an issue for me. I really appreciate all the help you have been providing.

from tmux-fzf.

ngocphamm avatar ngocphamm commented on June 7, 2024

But... yeah I just brought that minimal config to a virtual machine with NixOS to test, and it doesn't get the issue :( I think I will try gradually adding more config to it to see when it starts misbehaving.

Thank you for bearing with me on this. I will keep you posted (if you don't mind).

from tmux-fzf.

ngocphamm avatar ngocphamm commented on June 7, 2024

Update. Not sure if this is some kinda mac thing, but I just tried creating a brand new user on the mac, and started fresh. I loaded TPM with just this plugin. Then I started .zshrc with just export FZF_DEFAULT_OPTS='--height 40% --reverse', and this "bug" happens. The prompt is at the top for the first screen, but then at the bottom.

from tmux-fzf.

ngocphamm avatar ngocphamm commented on June 7, 2024

Yes I'm confident this is a mac thing. I just set up a mac virtual machine (running Catalina 10.15.7), and set up brew, to install tmux, fzf, fd, rg, and nothing else (well, Sublime Text to edit text), and this isuse happens right out of the box.

I have nothing but the 2 configuration files

.tmux.conf

### Plugins
set -g @plugin 'tmux-plugins/tpm'

set -g @plugin 'sainnhe/tmux-fzf'
TMUX_FZF_LAUNCH_KEY="C-f"
# TMUX_FZF_OPTIONS="-p -w 62% -h 38% -m --reverse"
TMUX_FZF_ORDER="pane|window|session|command|keybinding"

run '~/.tmux/plugins/tpm/tpm'

.zshrc

_has() {
  return $( whence $1 >/dev/null )
}

# FZF. Fuzzy file finder for shell & vim
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh

if _has fzf && _has rg && _has fd; then
  # rg, or fd commands need to be installed separately
  # https://github.com/sharkdp/fd
  # https://github.com/BurntSushi/ripgrep

  export FZF_DEFAULT_COMMAND='fd --type f --hidden --color never --exclude ".git"'
  # export FZF_DEFAULT_COMMAND='rg --color never --files --hidden --glob "!.git" 2> /dev/null'
  export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
  export FZF_ALT_C_COMMAND='fd --type d --hidden --color never ""'

  # So do cd ~~, nv conf~~, or ssh ~~, etc.
  export FZF_COMPLETION_TRIGGER='~~'

  # Or trigger completion with Ctrl-T
  # export FZF_COMPLETION_TRIGGER=''
  # bindkey '^T' fzf-completion
  # bindkey '^I' $fzf_default_completion

  # Some options:
  # --reverse
  # --border
  export FZF_DEFAULT_OPTS='--height 40% --reverse'
  export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden:wrap --bind 'ctrl-/:toggle-preview'"

  # https://github.com/fnune/base16-fzf/blob/master/bash/base16-ocean.config
  _gen_fzf_default_opts() {
    local color00='#2b303b'
    local color01='#343d46'
    local color02='#4f5b66'
    local color03='#65737e'
    local color04='#a7adba'
    local color05='#c0c5ce'
    local color06='#dfe1e8'
    local color07='#eff1f5'
    local color08='#bf616a'
    local color09='#d08770'
    local color0A='#ebcb8b'
    local color0B='#a3be8c'
    local color0C='#96b5b4'
    local color0D='#8fa1b3'
    local color0E='#b48ead'
    local color0F='#ab7967'

      export FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS"\
" --color=bg+:$color01,bg:$color00,spinner:$color0C,hl:$color0D"\
" --color=fg:$color04,header:$color0D,info:$color0A,pointer:$color0C"\
" --color=marker:$color0C,fg+:$color06,prompt:$color0A,hl+:$color0D"
    }

    _gen_fzf_default_opts

  # Use tmux popup, if it's available (tmux 3.2 exposes "$TERM_PROGRAM")
  if [ "$TERM_PROGRAM" = "tmux" ] && [ ! -z "$TMUX" ]; then
    export FZF_TMUX=1
    export FZF_TMUX_OPTS='-p 40%'
  fi

  # For ZSH command fuzzy completion. COMMAND [DIRECTORY/][FUZZY_PATTERN]**<TAB>
  # Use fd as it has option to filter by type, so we can get folders only
  _fzf_compgen_path() {
    fd --hidden --follow --exclude ".git" . "$1"
  }

  _fzf_compgen_dir() {
    fd --type d --hidden --follow --exclude ".git" . "$1"
  }
fi

Please let me know if you want to fix this issue, and if I can do anything to help.

from tmux-fzf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.