zsh-autosuggestions
zsh-autosuggestions copied to clipboard
only autosuggest files that exist
Autosuggest suggests me files that don't exist in this directory, e.g.
foo$ vim foofile
foo$ cd bar
foo/bar$ vim |
at the | point autosuggest is suggesting me foofile even though it doesn't exist in foo/bar.
For commands that work on paths I want to only be shown valid paths (from the current directory).
Can I make the suggestions more intelligent to solve this problem?
Check out my response to #340.
I'm going to re-open this since it is definitely what fish shell does and it would be really nice to have. zsh-histdb doesn't actually solve the problem in the way that fish does. Fish seems to save files/directories that a command references along with the command in the history entry. Then when retrieving a suggestion it skips commands that refer to files/directories that no longer exist.
I don't know how that can be implemented in zsh, but I think it's worth pursuing since it would bring this plugin closer to working just like fish. We may need something added upstream to keep track of which files were referenced by a given history command.
Some more test cases based on my observations with fish:
touch foo
rm foo
rm
Should not suggest rm foo since it no longer exists.
mkdir -p foo/bar/baz
echo 'foo/bar/baz'
rm -rf foo
echo
Should not suggest echo foo/bar/baz since it no longer exists.
mkdir -p foo/bar/baz
rm -rf foo
mkdir
Should suggest mkdir -p foo/bar/baz since at the time mkdir was run, foo/bar/baz did not exist.
Another test case:
Should suggest cat {foo,bar} even though they no longer exist.
touch {foo,bar}
cat {foo,bar}
rm {foo,bar}
cat
@ericfreese is there a news about this FISH-like feature?