Search code examples
terminalzshoh-my-zshzshrc

I have a custom alias for `ls -als` called `la` in my zshrc, and it's being overwritten by something as `ls -lAh`. Where is this coming from?


I have the following in my .zshrc

alias la="ls -als"

And it's being overwritten

▶︎ which la
la: aliased to ls -lAh

Why is this happening / where might it be coming from?


Solution

  • Helped largely by https://stackoverflow.com/a/26742455/413254, it turns out that oh-my-zsh has some built in directory aliases in ~/.oh-my-zsh/lib/directories.zsh one of which overwrote my custom one!

    ▶︎ cat directories.zsh
    # Changing/making/removing directory
    ...
    # List directory contents
    alias lsa='ls -lah'
    alias l='ls -lah'
    alias ll='ls -lh'
    alias la='ls -lAh'
    

    You could resolve this in a few ways:

    • Change my la alias to something else
    • Modify the above .oh-my-zsh file
    • Make sure that I'm defining my alias AFTER source $ZSH/oh-my-zsh.sh in my .zshrc. That source $ZSH/oh-my-zsh.sh sources basically everything in .oh-my-zsh/lib

    I went with the last option.