-
Notifications
You must be signed in to change notification settings - Fork 82
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
Expand tilde while searching files #109
Conversation
@@ -6,11 +6,12 @@ function __fzf_search_current_dir --description "Search the current directory. R | |||
set fd_arguments --hidden --color=always --exclude=.git | |||
set fzf_arguments --multi --ansi | |||
set token (commandline --current-token | string unescape) | |||
set expanded_token (string replace --regex -- "^~/" $HOME/ $token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact we can use an unquoted ~
instead of $HOME
here, but that would be too confusing 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally find string replace --regex -- "^~/" ~/ $token
more aesthetically pleasing, but this works too.
Nice work! Thanks @kidonng and thanks for helping review @jorgebucaran :) |
Evolved from #109. Now not only does tilde (~) in the current token get expanded, variables do as well. This is useful for quickly accessing known directory variables, e.g. $XDG_CONFIG_HOME, $TMPDIR, $JAVA_HOME, $fisher_path, $__fish_user_data_dir.
Before, vim ~/<ctrl-f> did not work. Users had to manually expand ~ (e.g. vim /Users/aaa/<ctrl-f> worked fine). This is because the test built-in and fd doesn't expand ~ automatically, so we have to expand it ourselves. Fixes PatrickF1#88
Evolved from PatrickF1#109. Now not only does tilde (~) in the current token get expanded, variables do as well. This is useful for quickly accessing known directory variables, e.g. $XDG_CONFIG_HOME, $TMPDIR, $JAVA_HOME, $fisher_path, $__fish_user_data_dir.
Fix #88
Fish's
test
andfd
doesn't expand~
automatically, so we need to expand it ourselves.