zsh alias being overridden somehow

6,055

Solution 1

You tagged the question with oh-my-zsh, but did not mention it in the question.

I suspect that oh-my-zsh is creating its own ls alias. If this happens after you define your alias, then it will override yours.

You should probably uncomment DISABLE_LS_COLORS="true" in your .zshrc, or put your alias after the line that does source $ZSH/oh-my-zsh.sh.

Solution 2

Create a file called custom.zsh in ~/.oh-my-zsh/custom/ and put your aliases in this file. These are loaded last in "oh-my-zsh".

Solution 3

It is probably in the global system .zshrc or equivalent. You should be able to put:

unalias ls
alias ls='ls -G -la'

That will delete the original alias and then create your alias

Share:
6,055

Related videos on Youtube

Jules
Author by

Jules

Expert Python programmer with experience working with the Linux network stack, REST APIs, and relational databases (and Postgres in particular). There's some devops experience in there too, but software dev is my preference. Not currently open to new work.

Updated on September 18, 2022

Comments

  • Jules
    Jules over 1 year

    I'm on a system running OS X 10.8.5.

    I recently tried to alias ls to ls -G -la command. I opened up ~/.zshrc, put in the alias, relaunched the terminal, but the change didn't take effect. Upon performing which ls, I found out that it's already being aliased to ls -G.

    This isn't behaviour I ever set up. Is there any way to find out where this alias is being set?

  • Jules
    Jules over 10 years
    Just tried that. I get no such hash table element: ls
  • kurtm
    kurtm over 10 years
    @atleastthreecharacters So then ls isn't aliased. What syntax are you using to define your alias?
  • Jules
    Jules over 10 years
    I'm using alias shortcut="full-command-name". But I know it's aliased, not just because of the reason I stated in my original question, but also because ls actually does display colour-coded results.