Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: ctrl-t start with current word in search #4276

Open
5 of 10 tasks
kaddkaka opened this issue Feb 23, 2025 · 2 comments
Open
5 of 10 tasks

Feature request: ctrl-t start with current word in search #4276

kaddkaka opened this issue Feb 23, 2025 · 2 comments

Comments

@kaddkaka
Copy link

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.58.0 (65db735)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

This is a new request for an existing closed issue: #3195 "Option for Ctrl-T to use current command-line content as a search pattern"

I believe I have a usecase that wasn't discussed in the previous issue where invoking ctrl-T and using the current WORD as a starting point would be useful: Opening png files with firefox.

The issue is that firefox tries to be helpful and among the completions doesn't include files it thinks you don't want to open. Example:

mkdir pictures
touch pictures/potato.png
firefox pictures/<TAB>

Result: potato.png does not get completed.

My FZF configuration:

source "$XDG_CONFIG_HOME/fzf/key-bindings.bash"
source "$XDG_CONFIG_HOME/bash/fzf-bash-completion.sh"
bind -x '"\t": fzf_bash_completion'

Firefox does support opening png:s so this is arguably an issue with firefox, but it would be nice to circumvent it by invoking ctrl-t as described here.

Questions: Are there situations when one would prefer that [a-z/] followed by <TAB> doesn't include the current word in the search pattern?

@junegunn
Copy link
Owner

Have you tried using fuzzy completion? i.e. firefox pictures/**<TAB>

My FZF configuration:

source "$XDG_CONFIG_HOME/fzf/key-bindings.bash"
source "$XDG_CONFIG_HOME/bash/fzf-bash-completion.sh"
bind -x '"\t": fzf_bash_completion'

This is quite different from our current recommendation.

Could you share how you ended up with it?

@kaddkaka
Copy link
Author

I probably invented source "$XDG_CONFIG_HOME/fzf/key-bindings.bash by myself, can't remember. The other two lines of config are from: https://github.com/lincheney/fzf-tab-completion

I removed that and tried with eval "$(fzf --bash)" as per the instructions now, and ** on it's own works, but firefox ** does not show anything. (Is firefox hijacking the completion mechanism before fzf get's to do anything?)

In a folder with this content:

.
├── a.html
├── b.png
├── c.svg
├── d.xml
└── subdir
  1. ls<TAB> lists all 5
  2. ls **<TAB> also lists all 5
  3. firefox <TAB> lists a.html and subdir
  4. firefox **<TAB> lists none

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants