dots/commonsh/10_alias

102 lines
2.3 KiB
Text
Raw Permalink Normal View History

#! /bin/sh
# colors
for dircolors in gdircolors dircolors ; do
2010-09-02 11:49:57 -05:00
if command -v $dircolors >/dev/null 2>&1 ; then
2009-08-28 18:05:55 -05:00
dircolor_text=''
if [ -f "${HOME}/.dir_colors" ] ; then
dircolor_text=`cat "${HOME}/.dir_colors"`
elif [ -f /etc/DIR_COLORS ] ; then
dircolor_text=`cat /etc/DIR_COLORS`
fi
2010-09-02 11:49:57 -05:00
if $dircolors --version 2>/dev/null | grep GNU >/dev/null 2>&1 ; then
2009-08-28 18:05:55 -05:00
dircolor_text="${dircolor_text}\nSTICKY_OTHER_WRITABLE 01;04;34;40"
dircolor_text="${dircolor_text}\nOTHER_WRITABLE 01;34;40"
fi
eval `echo "${dircolor_text}" | $dircolors -b -`
break
fi
done
# gimmie an editor, make it a nice vi clone
2009-04-06 23:57:53 -05:00
for EDITOR in vimx vim elvis vile nvi vi ; do
2010-09-02 11:49:57 -05:00
command -v $EDITOR >/dev/null 2>&1 && break
done
export EDITOR
# make the history editor the editor we want
FCEDIT=$EDITOR
export FCEDIT
2009-04-07 00:02:04 -05:00
# vimx -> vim
if [ "${EDITOR}" = vimx ] ; then
2009-04-07 00:04:21 -05:00
alias vim=vimx
2009-04-07 00:02:04 -05:00
fi
# aliases
alias cd..='cd ..'
# handles per OS aliases, fixes a few terms
case `uname -s` in
Linux|CYGWIN*)
alias ls="ls -h --color=auto"
alias grep='grep -d skip --color=auto'
;;
FreeBSD|Darwin|DragonFly)
2010-09-02 11:49:57 -05:00
if command -v top >/dev/null 2>&1 ; then
2009-04-03 23:23:04 -05:00
alias top="top -o cpu"
fi
2010-09-02 11:49:57 -05:00
if command -v gls >/dev/null 2>&1 ; then
alias ls="gls -h --color=auto"
2010-09-02 11:49:57 -05:00
elif ls --version 2>/dev/null | grep GNU >/dev/null 2>&1 ; then
alias ls="ls -h --color=auto"
else
LSCOLORS="ExGxFxDxCxDxDxHbaDEaEa"
export LSCOLORS
alias ls="ls -Gh"
fi
alias grep='grep -d skip --color=auto'
;;
Interix)
alias ls="ls --color"
;;
SunOS)
2010-09-02 11:49:57 -05:00
if command -v gls >/dev/null 2>&1 ; then
alias ls="gls -h --color=auto"
2010-09-02 11:49:57 -05:00
elif ls --version 2>/dev/null | grep GNU >/dev/null 2>&1 ; then
2009-01-14 22:15:09 -05:00
alias ls="ls -h --color=auto"
else
2009-01-14 22:15:09 -05:00
alias ls="ls -h"
fi
2010-09-02 11:49:57 -05:00
if command -v ggrep >/dev/null 2>&1 ; then
alias grep='ggrep -d skip --color=auto'
2010-09-02 11:49:57 -05:00
elif grep --version 2>/dev/null | grep GNU >/dev/null 2>&1 ; then
2009-01-14 22:15:09 -05:00
alias grep='grep -d skip --color=auto'
fi
for locate in glocate slocate ; do
2010-09-02 11:49:57 -05:00
command -v $locate >/dev/null 2>&1 && alias locate=$locate
done
;;
esac
2010-09-02 11:49:57 -05:00
if command -v gobjdump >/dev/null 2>&1 ; then
2010-03-11 13:44:23 -06:00
alias objdump=gobjdump
fi
2010-09-02 11:49:57 -05:00
if command -v ack-grep >/dev/null 2>&1 ; then
alias ack=ack-grep
fi
2009-01-23 14:36:03 -06:00
alias rm='rm -ir'
alias df='df -h'
alias du='du -h'
alias ping='ping -c4'
2010-09-02 11:49:57 -05:00
command -v time >/dev/null 2>&1 && alias time='command time'