One likely cause for the seeming difference in the output of ls -l
between zsh and bash is the use of Tab
-completion with AUTO_REMOVE_SLASH
enabled in zsh (which is the default).
AUTO_REMOVE_SLASH <D>
When the last character resulting from a completion is a slash and the next character typed is a word delimiter, a slash, or a character that ends a command (such as a semicolon or an ampersand), remove the slash.
When typing ls -l symb
Tab, both zsh
and bash
will complete this to ls -l symboliclink/
(note the /
at the end). The difference is that zsh
(with enabled AUTO_REMOVE_SLASH
) will remove the slash, if you just press Enter (i.e. end the command) there.
So you will effectively run ls -l symboliclink/
in bash, which tells ls -l
to look behind the link. But in zsh you will run ls -l symboliclink
, which tells ls -l
that you want to see the information about the link and not the target directory.
ls
without option -l
will always show the contents of the target directory, regardless of there being an /
at the end or not.
In order to get zsh to not remove the slash at the end, it is sufficient to just type it explicitly after TAB
-completion. Usually this will not visibly change the completed text, but if you type a space or confirm the command, the /
will remain. "Usually" because it is possible to set a highlighting for automatically added suffix characters, for example magenta and bold:
zle_highlight[(r)suffix:*]="suffix:fg=magenta,bold"
(Note: this may not work when using the external ZSH Syntax Highlighting plugin)
Another solution is (obviously) to disable AUTO_REMOVE_SLASH
. This can be done with
setopt noautoremoveslash