Reputation: 28122
In my bash shell, when my cursor is between text, and I hit Tab, it autocompletes the filename, and when I hit Enter, it inserts the completion at the cursor, and everything after the cursor remains, e.g.
$ cp foo.ba¦r.baz.py
^ <== cursor position
Hit the Tab key, and now I see:
$ cp foo.bar.baz.py¦r.baz.py
^ <== cursor position
I like this behavior, particularly when doing a mv
or cp
and want to modify the original filename. How can I get zsh to do the same thing?
Upvotes: 5
Views: 1480
Reputation: 301
Alternatively, you can add the _prefix
control function at the end of your zstyle ':completion:*' completer
command in your zshrc, so it will look something like this:
zstyle ':completion:*' completer _force_rehash _complete _list _match _prefix
You also need to enable completeinword
for this to work:
setopt completeinword
This way you aren't forced to use expansion like you would be by binding expand-or-complete-prefix
.
Upvotes: 1