Ubuntu: Setting up aliases in zsh
Channel: Roel Van de Paar
Date: 2019-06-21

Ubuntu: Setting up aliases in zsh


The Question: I know that in bash you can set up aliases in a .bash_aliases file so that the
command you type doesnt need to be a command stored in the binaries in the
system. Is there any way I can get aliases into zsh?

Solutions Sample (Please watch the whole video to see all solutions, in order of how many people found them helpful):

== This solution helped 38 people ==
you can do it by the "alias" command with this syntax:
alias [ -gmrL ] [ name[=value] ... ]
for "gmrL" switchs, see http://zsh.sourceforge.net/Doc/Release/Shell-
Grammar.html#Aliasing For each name with no value, zsh will print the name and
what it is aliased to previously. With no arguments at all, alias prints the
values of ALL defined aliases.
To define one or more aliases, simply enter
alias name1=value1 name2=value2 ... nameX=valueX
For each name with a corresponding value, zsh defines an alias with that value.
for further info, check out that link ;-)
Update: updated the dead link.

== This solution helped 7 people ==
You generally put them in ~/.zshenv. But many programs use /bin/sh (usually
bash) instead of $SHELL to execute shell commands, so for it to work everywhere
you will probably need to put the bash equivalent of the alias into
~/.bash_aliases anyway.

With thanks & praise to God! With thanks to the many people who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music: https://www.bensound.com/royalty-free-music | Images: https://stocksnap.io/license & others | With thanks to user Thomas Ward (https://askubuntu.com/users/10616), user sazary (https://askubuntu.com/users/12594), user Kurtosis (https://askubuntu.com/users/20362), user geekosaur (https://askubuntu.com/users/11775), and the Stack Exchange Network (http://askubuntu.com/questions/31216). Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything looks amiss at Roel D.OT VandePaar A.T gmail.com.