Skip to content

How to make fzf's CTRL-T and ALT-C work with zsh4humans? #366

Description

@sondhg

Before I installed zsh4humans, I could use the CTRL-T and ALT-C keybinds for choosing files and directories, based on official fzf documentation. The relevant parts in my old .zshrc was like this:

source <(fzf --zsh)
export FZF_DEFAULT_COMMAND='fd --hidden --strip-cwd-prefix --exclude .git'
export FZF_CTRL_T_COMMAND='fd --hidden --strip-cwd-prefix --exclude .git'
export FZF_ALT_C_COMMAND='fd --type d --hidden --strip-cwd-prefix --exclude .git'

Even if I didn't include the last 3 lines inside my old .zshrc, CTRL-T and ALT-C of fzf would still work (I just wanted to use fd because it is great).

But since I install zsh4humans, these two keybinds do not work, whether I add the above lines to my new .zshrc or not. I tried to mimic the behaviors by doing these:

  • Change zstyle ':z4h:fzf-complete' recurse-dirs 'no' to zstyle ':z4h:fzf-complete' recurse-dirs 'yes' in new .zshrc generated by zsh4humans. So when I type cd then hit Tab, it will show not only the directories in current level (e.g. ./dadfolder, ./momfolder), but also directories in levels deeper (e.g. ./dadfolder/child1/lol). This is not as convenient as just using ALT-C but at least it works.
  • However, I couldn't mimic the CTRL-T behavior of original fzf. It should let me search for any file within any folder nested inside the current working directory, no matter how deeply nested they are. I tried a command like code then hit Tab to bring up fzf search, but it works badly: if a folder has dot in its name (e.g. .config), it will not let me search for all files underneath it unless I accept the .config, then keep hitting Tab multiple times to go deeper. This is very inconvenient. And it also does not respect ignore rules, so it searches for files in node_modules too. Before I use zsh4humans, I could config this using export FZF_CTRL_T_COMMAND='fd --hidden --strip-cwd-prefix --exclude .git', but as mentioned, I can't now.

Any help on this would be greatly appreciated! zsh4humans has been really great for me so far, I just need to find a workaround for this fzf keybind problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions