Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to configure zsh to expand global aliases during tab completion? For example, I have the common aliases:

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

but when I type for example cd .../some<tab> it won't expand to cd .../something or cd ../../something. Consequently, I frequently won't use these handy aliases because I can't tab complete where I want to go.

share|improve this question

Try looking up zsh abbreviations. They allow you to enter an "abbreviation" which automatically gets replaced with its full form when you hit a magic key such as space. So you can create one which changes ...<SPACE> to ../...

For example, this is what you need in your profile:

typeset -A abbrevs
        "..." "../.."
        "...." "../../.."        

#create aliases for the abbrevs too
for abbr in ${(k)abbrevs}; do
   alias -g $abbr="${abbrevs[$abbr]}"

my-expand-abbrev() {
    local MATCH
    zle self-insert

bindkey " " my-expand-abbrev 
share|improve this answer

I have a custom ZLE widget for this, just drop it somewhere in a directory in $fpath. You can then configure it this way.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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