4

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
443

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

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 '12 at 19:13

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.