Change to Custom Directory Alias With Completions in Zsh

For quite some time, I’ve had a helper function on my Zsh config to quickly be able to cd to specific directories. It looked something like this:

function cdc() { cd “$HOME/Code/$1” }

So simply typing cdc or even cdc hacdias/hacdias.com would work perfectly. But there was a problem: I was seeing myself just typing cdc, pressing enter, and then “cding” to the right directory. This mostly happened because there was no autocomplete with this function.

Yesterday I decided to investigate how to enable autocomplete for this function and it’s actually pretty straightforward. To do so, you need to implement a definition function. It is standard to call it {name of alias}. Hence, in our case, it would be cdc.


Watch a movie through telnet:

telnet towel.blinkenlights.nl

I had this command saved for a long time and I thought it would be a nice idea to save it here.