speed up shells massively

This commit is contained in:
David Majnemer 2010-09-02 11:49:57 -05:00
parent c0851b91a3
commit 068b62e00d
8 changed files with 31 additions and 31 deletions

View file

@ -45,7 +45,7 @@ if [ -z "${MANPATH}" ] ; then
case `uname -s` in case `uname -s` in
SunOS) SunOS)
# some solaris systems have manpath # some solaris systems have manpath
if ( command -v manpath >/dev/null 2>&1 ) ; then if command -v manpath >/dev/null 2>&1 ; then
MANPATH=`manpath` MANPATH=`manpath`
export MANPATH export MANPATH
else else

View file

@ -4,7 +4,7 @@
fix_term () fix_term ()
{ {
# we were requested to go on screen and we are on a mac # we were requested to go on screen and we are on a mac
if ( infocmp $1 >/dev/null 2>&1 ) ; then if infocmp $1 >/dev/null 2>&1 ; then
echo $1 echo $1
else else
case $1 in case $1 in
@ -21,7 +21,7 @@ fix_term ()
fix_term screen-256colors fix_term screen-256colors
;; ;;
screen-256colors) screen-256colors)
if ( infocmp xterm-256colors >/dev/null 2>&1 ) ; then if infocmp xterm-256colors >/dev/null 2>&1 ; then
fix_term xterm-256colors fix_term xterm-256colors
else else
fix_term screen fix_term screen
@ -52,7 +52,7 @@ fix_terminfo_db ()
fi fi
} }
if ( command -v infocmp >/dev/null 2>&1 ) ; then if command -v infocmp >/dev/null 2>&1 ; then
# terminal surgery # terminal surgery
case `uname -s` in case `uname -s` in
Interix) Interix)
@ -70,7 +70,7 @@ if ( command -v infocmp >/dev/null 2>&1 ) ; then
# I am sorry to hear that you are running an # I am sorry to hear that you are running an
# xterm that has no colors (I am looking at you solaris) # xterm that has no colors (I am looking at you solaris)
if [ $TERM = xterm ] && ( command -v tput >/dev/null 2>&1 ) && [ `tput -T xterm colors` = -1 ] ; then if [ $TERM = xterm ] && command -v tput >/dev/null 2>&1 && [ `tput -T xterm colors` = -1 ] ; then
# lets see what we can do about your terrible term # lets see what we can do about your terrible term
TERM=`fix_term xterm-color` TERM=`fix_term xterm-color`
fi fi

View file

@ -1,7 +1,7 @@
#! /bin/sh #! /bin/sh
# colors # colors
for dircolors in gdircolors dircolors ; do for dircolors in gdircolors dircolors ; do
if ( command -v $dircolors >/dev/null 2>&1 ) ; then if command -v $dircolors >/dev/null 2>&1 ; then
dircolor_text='' dircolor_text=''
if [ -f "${HOME}/.dir_colors" ] ; then if [ -f "${HOME}/.dir_colors" ] ; then
dircolor_text=`cat "${HOME}/.dir_colors"` dircolor_text=`cat "${HOME}/.dir_colors"`
@ -11,7 +11,7 @@ for dircolors in gdircolors dircolors ; do
eval `$dircolors -b /etc/DIR_COLORS` eval `$dircolors -b /etc/DIR_COLORS`
fi fi
if ( $dircolors --version 2>/dev/null | grep GNU >/dev/null 2>&1 ) ; then if $dircolors --version 2>/dev/null | grep GNU >/dev/null 2>&1 ; then
dircolor_text="${dircolor_text}\nSTICKY_OTHER_WRITABLE 01;04;34;40" dircolor_text="${dircolor_text}\nSTICKY_OTHER_WRITABLE 01;04;34;40"
dircolor_text="${dircolor_text}\nOTHER_WRITABLE 01;34;40" dircolor_text="${dircolor_text}\nOTHER_WRITABLE 01;34;40"
fi fi
@ -23,7 +23,7 @@ done
# gimmie an editor, make it a nice vi clone # gimmie an editor, make it a nice vi clone
for EDITOR in vimx vim elvis vile nvi vi ; do for EDITOR in vimx vim elvis vile nvi vi ; do
( command -v $EDITOR >/dev/null 2>&1 ) && break command -v $EDITOR >/dev/null 2>&1 && break
done done
export EDITOR export EDITOR
@ -46,13 +46,13 @@ case `uname -s` in
alias grep='grep -d skip --color=auto' alias grep='grep -d skip --color=auto'
;; ;;
FreeBSD|Darwin|DragonFly) FreeBSD|Darwin|DragonFly)
if ( command -v top >/dev/null 2>&1 ) ; then if command -v top >/dev/null 2>&1 ; then
alias top="top -o cpu" alias top="top -o cpu"
fi fi
if ( command -v gls >/dev/null 2>&1 ) ; then if command -v gls >/dev/null 2>&1 ; then
alias ls="gls -h --color=auto" alias ls="gls -h --color=auto"
elif ( ls --version 2>/dev/null | grep GNU >/dev/null 2>&1 ) ; then elif ls --version 2>/dev/null | grep GNU >/dev/null 2>&1 ; then
alias ls="ls -h --color=auto" alias ls="ls -h --color=auto"
else else
LSCOLORS="ExGxFxDxCxDxDxHbaDEaEa" LSCOLORS="ExGxFxDxCxDxDxHbaDEaEa"
@ -65,31 +65,31 @@ case `uname -s` in
alias ls="ls --color" alias ls="ls --color"
;; ;;
SunOS) SunOS)
if ( command -v gls >/dev/null 2>&1 ) ; then if command -v gls >/dev/null 2>&1 ; then
alias ls="gls -h --color=auto" alias ls="gls -h --color=auto"
elif ( ls --version 2>/dev/null | grep GNU >/dev/null 2>&1 ) ; then elif ls --version 2>/dev/null | grep GNU >/dev/null 2>&1 ; then
alias ls="ls -h --color=auto" alias ls="ls -h --color=auto"
else else
alias ls="ls -h" alias ls="ls -h"
fi fi
if ( command -v ggrep >/dev/null 2>&1 ) ; then if command -v ggrep >/dev/null 2>&1 ; then
alias grep='ggrep -d skip --color=auto' alias grep='ggrep -d skip --color=auto'
elif ( grep --version 2>/dev/null | grep GNU >/dev/null 2>&1 ) ; then elif grep --version 2>/dev/null | grep GNU >/dev/null 2>&1 ; then
alias grep='grep -d skip --color=auto' alias grep='grep -d skip --color=auto'
fi fi
for locate in glocate slocate ; do for locate in glocate slocate ; do
( command -v $locate >/dev/null 2>&1 ) && alias locate=$locate command -v $locate >/dev/null 2>&1 && alias locate=$locate
done done
;; ;;
esac esac
if ( command -v gobjdump >/dev/null 2>&1 ) ; then if command -v gobjdump >/dev/null 2>&1 ; then
alias objdump=gobjdump alias objdump=gobjdump
fi fi
if ( command -v ack-grep >/dev/null 2>&1 ) ; then if command -v ack-grep >/dev/null 2>&1 ; then
alias ack=ack-grep alias ack=ack-grep
fi fi
@ -100,4 +100,4 @@ alias du='du -h'
alias ping='ping -c4' alias ping='ping -c4'
( command -v time >/dev/null 2>&1 ) && alias time='command time' command -v time >/dev/null 2>&1 && alias time='command time'

View file

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
for PAGER in less more pg ; do for PAGER in less more pg ; do
( command -v $PAGER >/dev/null 2>&1 ) && break command -v $PAGER >/dev/null 2>&1 && break
done done
export PAGER export PAGER

View file

@ -1,4 +1,4 @@
#! /bin/sh #! /bin/sh
for wrap in rlwrap rlfe cle ; do for wrap in rlwrap rlfe cle ; do
( command -v $wrap >/dev/null 2>&1 ) && alias ocaml="$wrap ocaml" && break command -v $wrap >/dev/null 2>&1 && alias ocaml="$wrap ocaml" && break
done done

View file

@ -14,13 +14,13 @@ err ()
E*) E*)
errconst=$1 errconst=$1
unset errno unset errno
if [ "${errno}" = "" ] && ( command -v python > /dev/null 2>&1 ); then if [ "${errno}" = "" ] && command -v python > /dev/null 2>&1 ; then
errno=`python -c "import errno;print(errno.${errconst})" 2>/dev/null` errno=`python -c "import errno;print(errno.${errconst})" 2>/dev/null`
fi fi
if [ "${errno}" = "" ] && ( command -v perl > /dev/null 2>&1 ); then if [ "${errno}" = "" ] && command -v perl > /dev/null 2>&1 ; then
errno=`perl -MErrno -e "print &Errno::${errconst}.\"\n\";" 2>/dev/null` errno=`perl -MErrno -e "print &Errno::${errconst}.\"\n\";" 2>/dev/null`
fi fi
if [ "${errno}" = "" ] && ( command -v ruby > /dev/null 2>&1 ); then if [ "${errno}" = "" ] && command -v ruby > /dev/null 2>&1 ; then
errno=`ruby -e "puts Errno::${errconst}::Errno" 2>/dev/null` errno=`ruby -e "puts Errno::${errconst}::Errno" 2>/dev/null`
fi fi
if [ "${errno}" = "" ] && [ -e /usr/include/errno.h ] ; then if [ "${errno}" = "" ] && [ -e /usr/include/errno.h ] ; then
@ -36,10 +36,10 @@ err ()
*) *)
errno=$1 errno=$1
unset errconst unset errconst
if [ "${errconst}" = "" ] && ( command -v ruby > /dev/null 2>&1 ); then if [ "${errconst}" = "" ] && command -v ruby > /dev/null 2>&1 ; then
errconst=`ruby -e "puts Errno.constants.find_all{|err| eval('Errno::' + err + '::Errno') == ${errno} }" 2>/dev/null` errconst=`ruby -e "puts Errno.constants.find_all{|err| eval('Errno::' + err + '::Errno') == ${errno} }" 2>/dev/null`
fi fi
if [ "${errconst}" = "" ] && ( command -v python > /dev/null 2>&1 ); then if [ "${errconst}" = "" ] && command -v python > /dev/null 2>&1 ; then
errconst=`python -c "import errno;print(errno.errorcode[${errno}])" 2>/dev/null` errconst=`python -c "import errno;print(errno.errorcode[${errno}])" 2>/dev/null`
fi fi
if [ "${errconst}" ] ; then if [ "${errconst}" ] ; then
@ -58,10 +58,10 @@ err ()
esac esac
unset errstr unset errstr
if [ "${errstr}" = "" ] && ( command -v perl > /dev/null 2>&1 ) ; then if [ "${errstr}" = "" ] && command -v perl > /dev/null 2>&1 ; then
errstr=`perl -MPOSIX -e 'print strerror($ARGV[0])."\n";' $errno` errstr=`perl -MPOSIX -e 'print strerror($ARGV[0])."\n";' $errno`
fi fi
if [ "${errstr}" = "" ] && ( command -v python > /dev/null 2>&1 ) ; then if [ "${errstr}" = "" ] && command -v python > /dev/null 2>&1 ; then
errstr=`python -c "import os;print(os.strerror($errno))" 2>/dev/null` errstr=`python -c "import os;print(os.strerror($errno))" 2>/dev/null`
fi fi
@ -89,7 +89,7 @@ extract ()
return return
fi fi
if ( command -v aunpack > /dev/null 2>&1 ) ; then if command -v aunpack > /dev/null 2>&1 ; then
aunpack "${1}" aunpack "${1}"
return return
fi fi

View file

@ -2,7 +2,7 @@
WORDCHARS='' WORDCHARS=''
# disable core dumps # disable core dumps
if ( ulimit -c >/dev/null 2>&1 ) ; then if ulimit -c >/dev/null 2>&1 ; then
ulimit -c 0 ulimit -c 0
fi fi

View file

@ -21,7 +21,7 @@ case "${TERM}" in
dumb) dumb)
;; ;;
*) *)
if ( command -v tput >/dev/null 2>&1 ) && [ `tput colors` != -1 ] ; then if command -v tput >/dev/null 2>&1 && [ `tput colors` != -1 ] ; then
RESETCOLOR=$'%{\e[00;00m%}' RESETCOLOR=$'%{\e[00;00m%}'
if [ -z "${SSH_TTY}" ] ; then if [ -z "${SSH_TTY}" ] ; then
HOSTCOLOR=$'%{\e[01;32m%}' HOSTCOLOR=$'%{\e[01;32m%}'