Version 5 ships with new improved behavior that is more intuitive, easy to learn, and makes typing commands much faster! Big thanks to @kidonng who came up with all of these features and worked tirelessly with me until they were perfected.
For users who use custom key bindings, please read the Migrating
section at the bottom.
Change directory without typing cd (#72)
To change directories faster without typing cd
, start with an empty command line and trigger the find file feature (Ctrl+F by default). After you select the desired directory, fzf.fish will automatically prepends a ./
to the directory so that your command line becomes ./directory_path
. Then, hit Enter one more time to cd there.
This works because Fish treats directory names starting with a .
as an implicit cd:
the shell will attempt to change directory without requiring cd if the name of a directory is provided (starting with ., / or ~, or ending with /).
Use the current token to pre-populate the fzf query, replace it with the selection (#73)
What is "the current token"? It's the word that under the cursor. e.g. for
cat filepath<CURSOR>
, current token =filepath
. If your cursor is not touching any words (e.g.cat filepath <CURSOR>
or `vim file), then there is no current token and none of the behavior below applies.
Now, all functions will
- use the current token (the word that is under the cursor) to pre-populate the fzf query, which will make searching faster
- replace the current token with the selection (if there is a current token), which will reduce hassle. The previous behavior of simply inserting the selection at the cursor meant that if there was a current token when the user triggered fzf.fish, that token would become mashed together with their first selection. By replacing the current token instead, users no longer have to go back and delete it to clean up their command.
A special case was made for searching for shell variables. If the current token begins with a $
, the $
is not overwritten when replacing the current token with the selected variable.
Shell variables search much more powerful (#71)
- Shell variable previews now use
set --show
which- shows which scopes the variable is defined in
- puts each element of the variable on its own line with the index number to make list variables much more readable
- You can know search for and inspect every single variable set in your current shell environment and scope, even if the variables are local and unexported. This is actually a major improvement as well as a bug fix. Before, search variables function actually used the variables from a different scope and the values form a different fish shell, so local variables were missing or variables had the wrong value. This is a problem if say, you wanted to inspect a local variable or inspect
$status
. Now, you will be able to see all the variables exactly as they are at the time you triggered fzf.fish. $history
is now excluded from the variables that can be searched for technical reasons, but also to encourage usage of the search command history feature.
Note: This change is backwards incompatible for users who set their own key binding. See the Migrating
section below.
Other changes
- Use
MM-DD
for the history date format, which is more readable and standard (#74) - minor performance improvements made by reducing the number of calls to
commandline
(part of #73)
Migrating
If you do not use custom key bindings, there is nothing you need to do to upgrade to v5. However, if you do, you need to update your key binding to call __fzf_search_current_dir
with two new arguments:
# If you use custom key bindings, change this...
bind \cv '__fzf_search_current_dir'
bind --mode insert \cv '__fzf_search_current_dir'
# ...to this...
set --local search_vars_cmd '__fzf_search_shell_variables (set --show | psub) (set --names | psub)'
bind \cv $search_vars_cmd
bind --mode insert \cv $search_vars_cmd
See conf.d/fzf.fish for more details.