I have an ZSH alias:

alias -g ...='../..'
alias -g ....='../../..'

When I try to cd ..., things work perfectly. I can't, however, use it in a cp command: cp .../file . fails with cp: .../file: No such file or directory.

In addition, trying to use the alias such: cd .../dir fails: cd:cd:10: no such file or directory: .../dir. Doing the same thing using cd ...; cd dir works fine.

From the zsh-lovers page:

Global aliases can be used anywhere in the command line. Example:

$ alias -g C='| wc -l'
$ grep alias ~/.zsh/* C

The ZSH Introduction also says that global aliases are substituted anywhere in the command line.

Why aren't my aliases being used as I thought they should be?

2 Answers 2


Maybe the reason is that the '...' in '.../file' is not space/boundry delimited?
e.g In the zsh-lovers example, 'C' is preceded by a space.

From another SU question I found the following that might help:
nicoulaj / dotfiles : rationalize-dots

  • 1
    this is my immediate thought, it's not seeing an alias, it's seeing .../file If you aliased C like then and then did mv myClass ~/src/ and it expanded the alias, that'd be a problem.
    – Rob
    Apr 6, 2012 at 19:13

In contrast to aliases, static named directory ~... will expand to ../.. inside paths, if defined as

$ hash -d ...=../..

For example,

$ cd /usr/share/zsh
$ readlink -m ~...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .