alias がどこで設定されてるか調べた

一つも alias を設定した覚えが無いのに、

% alias
l.='ls -d .* --color=tty'
ll='ls -l --color=tty'
ls='ls --color=tty'
run-help=man
which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
which-command=whence

と、いくつかエイリアスが登録されてたので、どこで登録されてるか調べてみた。


/etc/zshrc を覗いてみると、ログインシェルじゃなかったら、/etc/profile.d/*.sh を読み込んでいるみたい。(なんか微妙な設定だな…。)

% less /etc/zshrc
# 略
# from bashrc
if [ "x$SHLVL" != "x1" ]; then # We're not a login shell
    for i in /etc/profile.d/*.sh; do
        if [ -r "$i" ]; then
            . $i
        fi
    done
    unset i
fi
# 略


そこで、/etc/profile.d/*.sh に alias という行が無いか調べてみると、

% sudo perl -wnl -e '/alias/ and s/^\s*|\s*$//g and print "$ARGV $.:\t\t$_";' /etc/profile.d/*.sh | less
/etc/profile.d/colorls.sh 3:            alias ll='ls -l' 2>/dev/null
/etc/profile.d/colorls.sh 4:            alias l.='ls -d .*' 2>/dev/null
/etc/profile.d/colorls.sh 18:           alias ll='ls -l --color=tty' 2>/dev/null
/etc/profile.d/colorls.sh 19:           alias l.='ls -d .* --color=tty' 2>/dev/null
/etc/profile.d/colorls.sh 20:           alias ls='ls --color=tty' 2>/dev/null
/etc/profile.d/which-2.sh 158:          alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

お、あったあった。


/etc/profile.d/colorls.sh とかいうよく知らないところで設定されている。なんか気持ち悪いが、どこで設定されてるか分かったからとりあえずよしとしよう。