I'm just getting on the zsh train, and while a lot of my personal customisation work has been around getting zsh to look like my old bashrc setup, I just learnt of one new feature that I never used in bashrc that is going to make my zsh experience much more friendly, especially to those looking on when I'm coding.
Alias Expansion is a concept where when you declare an alias
alias serveme="python -m http.server 1337"
Instead of just typing the alias, you hit a key sequence and it expands for you
By using the globalias
ohmyzsh plugin, this automatically happens when you hit space.
$ servemeโ
$ python -m http.server 1337 โ
Which is really nifty because there's no extra key presses required, and it helps you remember the full command (extra points!).
But not only that, it means that you can greatly improve your demos especially when you have super long commands to run all the time.
For example:
$ tail ~/.zshrc
alias ka="kubectl apply -f"
$ kaโ
$ kubectl apply -f โ
Shout-out to Mark for the tip!
Top comments (2)
The expansion should also work with special symbols like
!!
and!$
.If you forgot to add
sudo
before running a command you can typesudo !!
+ space to get right one.I knew of the
sudo !!
trick, but I never used it because I'd prefer to โฌ and edit to know exactly what I was running. This is a super useful extra trick! Thank you!