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
Share:
9,252

Related videos on Youtube

Dimitar
Author by

Dimitar

Updated on September 18, 2022

Comments

  • Dimitar
    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 run pa I am getting an error zsh: command not found: pa why is that?

    • C0deDaedalus
      C0deDaedalus about 6 years
      Have you sourced the file ? Try this source ~/.aliases and then run commands.
    • Dimitar
      Dimitar about 6 years
      i found my problem i wrote it as an answer so someone in need like me can read it.
  • mostafaznv
    mostafaznv almost 4 years
    right approach.