-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Fish history file path detection is broken for path prefixed with ~
#7582
Comments
After looking at the code, it seems that the function that decide if a path should be added is path_is_valid, and that it is not performing tilde expansion. I spend a bit of time trying to add expand_tilde to I tried to add I see 3 options:
|
Hi, thanks for the detailed write-up. This issue also applies to paths with variables, like in
It seems that fish sets HOME if it doesn't exist - of course that doesn't solve the problem for other variables.
Right, in I'm not yet sure what is the best solution. We could copy relevant variables. However, it's probably simpler to capture a reference to the environment, and use our |
Ok, I'll try to have a look at passing by reference + use a mutex. in the end it might enable arbitrary variable expansion, which should be even more consistent. If it doesn't work there is already a special getter for I'll experiment a bit if that's alright. |
Sounds good - probably you can pass an entire |
All files prefixed with `~` were not detected properly as valid files. Fix: fish-shell#7582
All files prefixed with `~` were not detected properly as valid files. Fix: fish-shell#7582
I have pushed a first version as a PR, it might be better to continue the discussion about the implementation there. |
When adding a command to history, we first expand its arguments to see if any arguments are paths which refer to files. If so, we will only autosuggest that command from history if the files are still valid. For example, if the user runs `rm ./file.txt` then we will remeber that `./file.txt` referred to a file, and then only autosuggest that if the file is present again. Prior to this change we only performed simple expansion relative to the working directory. This change extends it to variables and tilde expansion. For example we will now apply the same hinting for `rm ~/file.txt` Fixes fish-shell#7582
Version: 3.1.0
OS: Ubuntu focal
Terminal: st
Thank you for this project, I have been using fish for years and I love it. I looked at the issues but could not find one like this.
How to reproduce
When I looked at my
~/.local/share/fish/fish_history
file, I found that files starting with~
weren't detected properly as paths:Expectations
Comments
I do not know if it is really an issue or not, but it explain a few questions that I had in the past where I noticed that the autocomplete was inconsistent, and couldn't really understand why.
The text was updated successfully, but these errors were encountered: