Why is my alias not working in Zsh?
9,252
Solution 1
The problem was that I was editing the wrong file.
I edited my ~/.zshrc
file to add the aliases. Everything works fine after that.
Solution 2
Alternatively, you can keep your aliases in ~/.aliases
file itself which can be portable across systems but then add below lines at the end of ~/.zshrc
to include all of them
#...more zsh config above
if [ -f ~/.aliases ]; then
. ~/.aliases
fi
Related videos on Youtube
Author by
Dimitar
Updated on September 18, 2022Comments
-
Dimitar over 1 year
I have added my alias to
~/.aliases
file and the file right now is like this:alias gss="git status" alias gl="git log" alias pa="php artisan" alias reload=". ~/.zshrc && echo 'ZSH config reloaded from ~/.zshrc'"
When I run
gss
,gl
,reload
they all work, but when I runpa
I am getting an errorzsh: command not found: pa
why is that?-
C0deDaedalus about 6 yearsHave you sourced the file ? Try this
source ~/.aliases
and then run commands. -
Dimitar about 6 yearsi found my problem i wrote it as an answer so someone in need like me can read it.
-
-
mostafaznv almost 4 yearsright approach.