The alias
command overrides a previous alias by the same name. So generally, if you want your aliases to override the ones defined by a zsh framework, put them at the end of your .zshrc
. The same goes for other things such as function definitions, variable assignments, key bindings, etc. Generally speaking, the latest definition wins.
An edge case of “latest definition wins” is that it's only the latest definition for the same kind of object. In particular, aliases, functions and external commands are different kinds of objects, and for example defining a function after defining an alias of the same name does not override the alias. You need to call unalias
first. (Also note that the syntax foo () { … }
when foo
is an alias expands the alias — make sure to unalias
first, or use the function foo { … }
syntax.)
Occasionally a setting can be overridden at runtime through hook functions. For example frameworks to help with version control often change variables and possibly aliases or functions when entering or leaving a version-controlled directory. When this happens, you have to modify the existing hook or run your own hook after the one you don't fully like.
If you can't figure out where an alias is set, run script -c 'zsh -x'
, then type exit
. This creates a file called typescript
with a log of all the commands that zsh runs during its initialization. In that file, search for alias ls=
. (It could also be something like alias foo=bar ls=whatever
.)
grep -RIF 'ls --color=tty' ~
and with the output, I believe.oh-my-zsh/lib/theme-and-appearance.zsh
is the file causing this.unalias ls
, and add--color=tty
to your alias, OR change the name of your alias tofls
. Check withtype ls
to see whatls
means to your shell.