Replies: 16 comments 1 reply
-
What about searching for files under a path that has already been typed in the command?
Or am I just not used to fzf enough yet? |
Beta Was this translation helpful? Give feedback.
-
Hi @paddor, interesting use-case. That's really clever, but that's also really hard to implement and it'll also require a completely new command since the search files feature is intended and is probably understood by users to always search the current directory. Let me keep thinking about it. |
Beta Was this translation helpful? Give feedback.
-
I saw FZF mention this feature as CTRL-T. Maybe you can build on that. |
Beta Was this translation helpful? Give feedback.
-
Just found this exciting plugin and found that it lacks |
Beta Was this translation helpful? Give feedback.
-
Hey @wawa19933 sorry to disappoint but I don't plan on implementing that for now. I want to keep the plugin laser focused on completing commands quicker, not executing commands for you. That keeps the code, documentation, learning curve, and maintenance of the plugin (including what features to add or exclude) much easier. However, who knows? Maybe I or someone else will start another fzf plugin that executes commands for you. |
Beta Was this translation helpful? Give feedback.
-
@wawa19933 actually, there is now something nearly as good as an It only requires you to hit enter one extra time after using selecting the directory. |
Beta Was this translation helpful? Give feedback.
-
Hey, I am bit new to
will yield the desired results. First, a check is performed to see whether the token under the cursor is a directory or not. If it is, then it will be the base directory when calling |
Beta Was this translation helpful? Give feedback.
-
Hi @imr0, no it's not rough around the edges at all! Your use of fzf's API is splendid! Thank you for your suggestion. |
Beta Was this translation helpful? Give feedback.
-
I find the behavior of @imr0’s function way more intuitive than #73. And it’s faster. Why I think it’s more intuitive: When you’re typing your command, and start typing a path using TAB because of years of muscle memory, you’re not thinking about FZF yet. Simple directory scoping should apply. However, if you know you wanna use your current token as the FZF query, you might as well hit ^F first and then type your query. |
Beta Was this translation helpful? Give feedback.
-
Something that doesn't work with #73 is searching in a parent-sibling directory, like |
Beta Was this translation helpful? Give feedback.
-
@paddor It has nothing to do with the PR. This command is called search currect dir. |
Beta Was this translation helpful? Give feedback.
-
So for anyone who wants ^F to search the current directory OR the one you've just typed, put this into function __fzf_search_this_dir --description "Search this directory (CWD or typed directory) using fzf and fd. Insert the selected relative file path into the commandline at the cursor."
# Token under cursor
set --local token (string unescape (commandline --current-token))
if test -d $token
# Add trailing slash if not present
string match -qr '[^/]$' $token && set token $token/
# Use $token as base directory and concatenate file paths with it
set file_paths_selected $token(
fd --hidden --color=always --exclude=.git --exclude=.hg . $token |
fzf --multi --ansi --preview='__fzf_preview_file {}' --prompt=$token
)
else
set file_paths_selected (
fd --hidden --color=always --exclude=.git --exclude=.hg |
fzf --multi --ansi --preview='__fzf_preview_file {}' --query=$token
)
end
if test $status -eq 0
# If this function was triggered with an empty commandline and the only thing selected is a directory, then
# prepend ./ to the dir path. Because fish will attempt to cd implicitly if a directory name starting with a dot
# is provided, this allows the user to hit Enter one more time to quickly cd into the selected directory.
if test (count (commandline --tokenize)) = 0 && test (count $file_paths_selected) = 1 && test -d $file_paths_selected
set file_paths_selected ./$file_paths_selected
end
commandline --current-token --replace (string escape $file_paths_selected | string join ' ')
end
commandline --function repaint
end And this into bind \cf '__fzf_search_this_dir'
if test "$fish_key_bindings" = 'fish_vi_key_bindings'
bind --mode insert \cf '__fzf_search_this_dir'
end |
Beta Was this translation helpful? Give feedback.
-
@paddor I have opened a PR about @imr0's sugggestion, please give your thoughts there 👋 |
Beta Was this translation helpful? Give feedback.
-
I also wrote a little function (inspired by the official zsh script for
One could then bind it to let's say Ctrl+K (as in K for kill).
What do you think? |
Beta Was this translation helpful? Give feedback.
-
Hey @imr0, yes, I do plan on adding something like that. Thanks for getting me started. I'd prefer to keep the functions generic so they can apply to as many use cases as possible. So I'd probably set one up for finding pid, which can then be used in conjunction with a kill, pkill, or some command to cat /proc/:pid/* |
Beta Was this translation helpful? Give feedback.
-
Closing this now that v5 has been released but please feel free to open more issues for suggestions. |
Beta Was this translation helpful? Give feedback.
-
This'll be my scratch space for what I plan to include in the next major release. For anything seeing this, feel free to chime in!
Configurability
fzf.fish, now that it has reached a broader audience, should cater to more users by being more configurable.
One thing many people have asked for configurability on is the preview file functionality. Areas to make configurable
ls command for previewing dirs(done in Make preview directory command configurable #120)Other
Post v5 edit:
Things that were done / in progress
I've changed my mind about configurability. Not to the idea in general if there's a sound case to be made for it, but in regards to making the search files feature more configurable. See my reasoning here. But tl;dr I don't want to compete with file managers which have solved the problem of navigating directories, previewing files, and opening them a million times over and way better than I can.
Everything else above I will consider for minor releases for 5.x
Beta Was this translation helpful? Give feedback.
All reactions