zsh-users / zsh-autosuggestions

Fish-like autosuggestions for zsh
MIT License
31.34k stars 1.87k forks source link

only autosuggest files that exist #426

Open ghost opened 5 years ago

ghost commented 5 years ago

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?

ericfreese commented 5 years ago

Check out my response to #340.

ericfreese commented 5 years ago

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.

ericfreese commented 5 years ago

Another test case:

Should suggest cat {foo,bar} even though they no longer exist.

touch {foo,bar}
cat {foo,bar}
rm {foo,bar}
cat
D3vil0p3r commented 1 year ago

@ericfreese is there a news about this FISH-like feature?

segln commented 1 month ago

Still waiting for this ;)