6

In zsh, when I press tab 2 times to enter the "completion menu", select a directory and press enter, it first adds the chosen directory with a trailing slash to the command, but as soon as I press space to add more arguments, it removes it.

i.e. "rsync foo/" gets changed to "rsync foo " after pressing space.

Is there a way to disable this behaviour?

It forces me to always add slashes manually for commands like rsync in particular.

  • 5
    Just type the /. Or use unsetopt AUTO_REMOVE_SLASH. – Stéphane Chazelas Oct 8 '14 at 12:14
8

To retain the / added after completing directories or symbolic links to directories, turn off the option auto_remove_slash which is on by default.

setopt no_auto_remove_slash

For many commands, retaining the trailing slash makes no difference for directories, but causes the command to act on the target directory instead of the symbolic link if the argument is a symbolic link to a directory. For an rsync source argument, a trailing slash causes the directory to be merged into the destination rather than copied to a subdirectory.

  • This works great for local paths, but for me it doesn’t affect remote paths like example.com:some/dir/. Any idea? – Olivier 'Ölbaum' Scherler Nov 20 '17 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.