Zsh, directory tab-completion with prefix
Here's an example from my own .zshrc
that I keep as a copy/paste snippet:
# Try using the below template to set up zsh functions that act
# as aliases to cd and allow you to get autocomplete nicely.
project() { cd /path/to/project/$1; }
compctl -W /path/to/project/ -/ project
Just edit the /path/to/project
section in both lines above then you are good to go.
A different way of achieving a similar effect is to define aliases for directories:
setopt auto_cd
alias -d s=~/projects
Type ~s/
Tab to change to a subdirectory of ~/projects
; you can use ~s
in a command argument, too.