fzf-zsh-plugin icon indicating copy to clipboard operation
fzf-zsh-plugin copied to clipboard

CTRL-t not working in zsh

Open Dhruv-mak opened this issue 2 years ago • 8 comments

I am using oh-my-zsh for managing my zsh configuration. I installed fzf-zsh-plugin via these instructions.I have just installed Ubuntu:20.04.3 LTS. I went through this issue. but my ~/.zshrc contains this lines.

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

the CTRL-r is working perfectly. But when i press Alt-c or CTRL-t it gives me error msg that:

(eval):1: unknown file attribute:
   <  0/0 (0)

The output of bindkey | grep fzf is:

"^I" fzf-completion
"^R" fzf-history-widget
"^T" fzf-file-widget
"^[c" fzf-cd-widget

Dhruv-mak avatar Jan 02 '22 19:01 Dhruv-mak

Odd, things are working on my system. What's the output of printenv | grep FZF?

unixorn avatar Jan 03 '22 13:01 unixorn

Also, does which fzf-file-widget or which fzf-cd-widget show that they ended up defined?

unixorn avatar Jan 03 '22 13:01 unixorn

The output of printenv | grep FZF is:

FZF_DEFAULT_COMMAND=find . -type f ( -path .git -o -path node_modules ) -prune
FZF_ALT_C_COMMAND=find . -type d ( -path .git -o -path node_modules ) -prune
FZF_DEFAULT_OPTS=--layout=reverse
FZF_CTRL_T_COMMAND=find . -type f ( -path .git -o -path node_modules ) -prune

The output for which fzf-file-widget is:

fzf-file-widget () {
	LBUFFER="${LBUFFER}$(__fsel)" 
	local ret=$? 
	zle reset-prompt
	return $ret
}

And the output of which fzf-cd-widget is:

fzf-cd-widget () {
	local cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune     -o -type d -print 2> /dev/null | cut -b3-"}" 
	setopt localoptions pipefail no_aliases 2> /dev/null
	local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m)" 
	if [[ -z "$dir" ]]
	then
		zle redisplay
		return 0
	fi
	zle push-line
	BUFFER="cd -- ${(q)dir}" 
	zle accept-line
	local ret=$? 
	unset dir
	zle reset-prompt
	return $ret
}

Dhruv-mak avatar Jan 05 '22 03:01 Dhruv-mak

I'm getting a new work laptop Monday and will take a look at this in the clean environment on there before installing my dotfiles.

unixorn avatar Jan 08 '22 15:01 unixorn

It is working on my new work laptop. I'm loading it via zgenom instead of oh-my-zsh, though.

unixorn avatar Jan 13 '22 20:01 unixorn

I even tried it with zgenom. it's still not working for me.

Dhruv-mak avatar Mar 03 '22 13:03 Dhruv-mak

I seem to be hitting some variation of this issue as well. Ctrl-R works, Alt-C gives:

(eval):1: unknown file attribute:
   <  0/0 (0)

Unsetting FZF_ALT_C_COMMAND takes away the error but leaves me with an empty list to choose from. I tried opening a new terminal and running the command in FZF_ALT_C_COMMAND manually:

❯ printenv | grep FZF_ALT_C
FZF_ALT_C_COMMAND=find . -type d ( -path .git -o -path node_modules ) -prune

❯ find . -type d ( -path .git -o -path node_modules ) -prune

zsh: unknown file attribute:

On my previous laptop, I did not use this plugin but instead opted for manually sourcing the files available at /usr/share/fzf/*.zsh. I looked at the code present there which among other contains:

# ALT-C - cd into the selected directory
fzf-cd-widget() {
  local cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
    -o -type d -print 2> /dev/null | cut -b3-"}"
  setopt localoptions pipefail no_aliases 2> /dev/null
  local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m)"

I tried manually exporting that command in my own terminal:

export FZF_ALT_C_COMMAND="find -L . -mindepth 1 \( -path '*/\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \) -prune  -o -type d -print 2> /dev/null | cut -b3-"

Alt-C works as expected: Screenshot_2022-04-29-08-49-08_3840x2400

Ctrl-T works but gives me weird rendering issues related to No such file or directory (the files are symlinks with deleted targets): Screenshot_2022-04-29-08-43-46_3840x2400

Unsetting FZF_CTRL_T_COMMAND fixes the rendering issue.

I am running into this on a very clean arch linux installation with oh-my-zsh after following the simple installation instructions detailed in this repository. exa, rg, bat are installed through official repositories

My ~/.zshrc contains the following: plugins=(git zsh-autosuggestions zsh-syntax-highlighting zsh-vim-mode zsh-vimode-visual virtualenv kubectl sudo fzf fzf-zsh-plugin)

I've experimented with placing fzf-zsh-plugin and fzf both at the start and end of array, removing fzf, with no change in behavior.

To rule out conflicting plugins, I also just tried plugins=(fzf-zsh-plugin) with the same result.

fiskhest avatar Apr 29 '22 19:04 fiskhest

I have the same issue as @fiskhest... Didn't find a proper solution though

a-monteiro avatar Sep 11 '22 20:09 a-monteiro

Error is in FZF_DEFAULT_COMMAND. My zsh throw error when tries eval 'find . -type f ( -path .git -o -path node_modules ) -prune' I have just removed this plugin. And replace it with standart one from oh-my-zsh (plugins=("fzf"))

Pavel1114 avatar Jan 21 '23 11:01 Pavel1114

I seem to be hitting some variation of this issue as well. Ctrl-R works, Alt-C gives:

(eval):1: unknown file attribute:
   <  0/0 (0)

Unsetting FZF_ALT_C_COMMAND takes away the error but leaves me with an empty list to choose from. I tried opening a new terminal and running the command in FZF_ALT_C_COMMAND manually:

❯ printenv | grep FZF_ALT_C
FZF_ALT_C_COMMAND=find . -type d ( -path .git -o -path node_modules ) -prune

❯ find . -type d ( -path .git -o -path node_modules ) -prune

zsh: unknown file attribute:

On my previous laptop, I did not use this plugin but instead opted for manually sourcing the files available at /usr/share/fzf/*.zsh. I looked at the code present there which among other contains:

# ALT-C - cd into the selected directory
fzf-cd-widget() {
  local cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
    -o -type d -print 2> /dev/null | cut -b3-"}"
  setopt localoptions pipefail no_aliases 2> /dev/null
  local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m)"

I tried manually exporting that command in my own terminal:

export FZF_ALT_C_COMMAND="find -L . -mindepth 1 \( -path '*/\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \) -prune  -o -type d -print 2> /dev/null | cut -b3-"

Alt-C works as expected: Screenshot_2022-04-29-08-49-08_3840x2400

Ctrl-T works but gives me weird rendering issues related to No such file or directory (the files are symlinks with deleted targets): Screenshot_2022-04-29-08-43-46_3840x2400

Unsetting FZF_CTRL_T_COMMAND fixes the rendering issue.

I am running into this on a very clean arch linux installation with oh-my-zsh after following the simple installation instructions detailed in this repository. exa, rg, bat are installed through official repositories

My ~/.zshrc contains the following: plugins=(git zsh-autosuggestions zsh-syntax-highlighting zsh-vim-mode zsh-vimode-visual virtualenv kubectl sudo fzf fzf-zsh-plugin)

I've experimented with placing fzf-zsh-plugin and fzf both at the start and end of array, removing fzf, with no change in behavior.

To rule out conflicting plugins, I also just tried plugins=(fzf-zsh-plugin) with the same result.

I ran to the same trap as you when I installed fzf-zsh-plugin. Then I removed the plugin and tried fzf with sourcing the official config files /usr/share/doc/fzf/examples/*.zsh in my ~/.zshrc, but the result is the same. I tried printenv | grep FZF to list environment variables corelated to FZF, it turns out that they were set as wrong values. The installation process of fzf with apt will not introduce them. They may be introduced by fzf-zsh-plugin. The function __fsel() in key-bindings.zsh first check env variable FZF_CTRL_T_COMMAND, when it is empty, the later command will be adopted. So the probable solution is unset vars_fzf. Actually, it works for me.

nations-Xiong avatar Nov 28 '23 05:11 nations-Xiong

I'm using the fzf-zsh-plugin for oh-my-zsh. And I realized that the plugin search for either fdfind or find. And if fdfind is not found, then it sets the env verialbes to work with find. I solved it with:

sudo apt install fd-find

Then I started a new shell and the variables were set to work with fdfind which solved the problem. The file I looked into is located in $HOME/.oh-my-zsh/custom/plugins/fzf-zsh-plugin/fzf-zsh-plugin.plugin.zsh. A plugin from https://github.com/unixorn/fzf-zsh-plugin

svic321 avatar Jan 04 '24 13:01 svic321

that's right installing fd-find fix the problem

@unixorn can you add as requirement?

cognitus avatar Feb 18 '24 16:02 cognitus

As of #50, the plugin doesn't use fdfind unless it finds it in $PATH, so I think this is fixed.

unixorn avatar Mar 06 '24 18:03 unixorn