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

Expand tilde while searching files #109

Merged
merged 1 commit into from
Jan 30, 2021
Merged

Conversation

kidonng
Copy link
Contributor

@kidonng kidonng commented Jan 30, 2021

Fix #88

Fish's test and fd doesn't expand ~ automatically, so we need to expand it ourselves.

image

@@ -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)
Copy link
Contributor Author

@kidonng kidonng Jan 30, 2021

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 😄

Copy link
Contributor

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.

@PatrickF1
Copy link
Owner

Nice work! Thanks @kidonng and thanks for helping review @jorgebucaran :)

@PatrickF1 PatrickF1 merged commit 313672a into PatrickF1:main Jan 30, 2021
PatrickF1 pushed a commit that referenced this pull request Mar 23, 2021
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.
hrshtst pushed a commit to hrshtst/fzf.fish that referenced this pull request Apr 22, 2021
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
hrshtst pushed a commit to hrshtst/fzf.fish that referenced this pull request Apr 26, 2021
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.
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

Successfully merging this pull request may close these issues.

file paths doesn't work with tilde ~ prefix
3 participants