Oh-my-zsh aliases do not autocomplete
alias, autocomplete, plugins, zsh, zshrc
Solution
Aliases are essentially just short names for commands. Before executing a command zsh internally replaces aliases by their values. But by default aliases are not expanded when using completion (Tab), they are handled just like any other command.
For example:
alias ll='ls -l'
alias la='ls -al'
If you now type `l`Tab, zsh will present you every command starting with an `l`, including the aliases `ll` and `la`. If you type `ll`Tab it will probably just add an space after `ll` (assuming there are no other commands starting with `ll`).
When you run `ll somedir` it does the exact same thing as `ls -l somedir`. You can even add other options of `ls`: `ll -t somedir` runs `ls -l -t somedir`.
That being said, if you want to expand aliases when typing Tab, `zsh` can do so.
There are two ways:
You can call the `_expand_alias` widget. In emacs mode (bindkey -e) this is bound to `^Xa` (press Control+X then A).
You can add `_expand_alias` to the `completer` style. It seems that oh-my-zsh does not change this style from its default value, so adding
`zstyle ':completion:*' completer _expand_alias _complete _ignored`
to your `~/.zshrc` should work.
(To be save you can print the current setting with `zstyle -L ':completion:*' completer`, `_expand_alias` has to come before `_complete`)
If you now type `ll`Tab, `zsh` will replace it with `ls -l` immediatelly.
Note: in both cases the cursor has to be in or just after the alias for the replacement to happen. This also means you have to type the whole alias or backspace if automatically completed (`_completer` adds a space after successful completion)
Problem
I am a bit out of my wits researching this... and I just have to ask. I have oh-my-zsh on my Mavericks machine and have everything updated. I also have Xcode and Brew. All updated. According to this page: https://github.com/robbyrussell/oh-my-zsh/wiki/Cheatsheet am I not supposed to just type, say: "g" [tab] and get "git"? or type "md" [tab] and get "mkdir -p"? Right now I just get a list of options I can tab through (or arrow through)... I thought it would autocomplete. What am I missing? I have a feeling it might be related to my $PATH but that is where I also get confused... where should it point to? I greatly appreciate and enlightenment. ``` # Path to your oh-my-zsh configuration. #ZSH=$HOME/.oh-my-zsh export ZSH=$HOME/.oh-my-zsh # Set name of the theme to load. # Look in ~/.oh-my-zsh/themes/ # Optionally, if you set this to "random", it'll load a random theme each # time that oh-my-zsh is loaded. #ZSH_THEME="af-magic" ZSH_THEME="agnoster" # Set to this to use case-sensitive completion # CASE_SENSITIVE="true" # Comment this out to disable weekly auto-update checks # DISABLE_AUTO_UPDATE="true" # Uncomment following line if you want to disable colors in ls # DISABLE_LS_COLORS="true" # Uncomment following line if you want to disable autosetting terminal title. # DISABLE_AUTO_TITLE="true" # Uncomment following line if you want red dots to be displayed while waiting for completion COMPLETION_WAITING_DOTS="true" # Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) # Example format: plugins=(rails git textmate ruby lighthouse) plugins=(git textmate sublime zsh-syntax-highlighting) source $ZSH/oh-my-zsh.sh #export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/git/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/X11/$ #export PATH=$HOME/bin:/usr/local/bin:$PATH export PATH=/usr/local/bin:$PATH [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" zstyle ':completion:*' list-prompt '' zstyle ':completion:*' select-prompt '' autoload -Uz compinit compinit ```