Skip to content

Instantly share code, notes, and snippets.

@skreuzer
Created May 27, 2014 20:22
Show Gist options
  • Save skreuzer/75dc70e240c07b763ce1 to your computer and use it in GitHub Desktop.
Save skreuzer/75dc70e240c07b763ce1 to your computer and use it in GitHub Desktop.
set -o noclobber
set -o vi
stty erase '^?'
PATH=$PATH:~/bin
CVS_RSH=ssh
if [ -d ~/.history ]; then
HISTFILE=~/.history/hist.$(tty | sed 's;.*/;;')
else
HISTFILE=~/.history
fi
HOSTNAME=`hostname | cut -d. -f1`
if [ `which vim` ]; then
VISUAL=`which vim`
alias vi=vim
else
VISUAL=vi
fi
EDITOR=$VISUAL
case `uname -s` in
SunOS)
for EXTRADIR in `echo /opt/sfw/bin /opt/csw/bin /usr/ccs/bin /opt/SUNWjet/bin`; do
if [ -d $EXTRADIR ]; then
PATH=$PATH:$EXTRADIR
fi
done
whoami() {
/bin/expr "`/bin/id`" : '[^(]*(\([^)]*\)'
}
# pcpu - The ratio of CPU time used recently to CPU time available in the same period, expressed as a percentage.
# pid - The decimal value of the process ID.
# user - The effective user ID of the process.
# args - The command with all its arguments as a string.
alias sps="ps -edf -o pcpu,pid,user,args"
;;
NetBSD)
if [ -d /usr/pkg ]; then
PATH=$PATH:/usr/pkg/bin:/usr/pkg/sbin
fi
export PKG_PATH="ftp://ftp.netbsd.org/pub/NetBSD/packages/4.1/i386/All"
;;
Linux)
alias grep='GREP_COLOR="1;33" LANG=C grep --color=auto'
alias ls="BLOCK_SIZE=\'1 ls --color=auto"
alias units='units -t'
alias diff='LC_ALL=C TZ=GMT0 diff -Naur'
alias xterm='xterm -fb "" -bg black -fg gray -sl 3000 -g 80x50+1+1'
gray() {
yes "$(seq 232 255;seq 254 -1 233)" | \
while read i;
do
printf "\x1b[48;5;${i}m\n";
sleep .01;
done
}
matrix() {
tr -c "[:digit:]" " " < /dev/urandom | \
dd cbs=$COLUMNS conv=unblock | \
GREP_COLOR="1;32" grep --color "[^ ]"
}
;;
esac
pushd() {
dirname=$1
cd ${dirname:?"Missing directory name."}
DIRSTACK="$PWD ${DIRSTACK:-$OLDPWD}"
print "$DIRSTACK"
}
popd() {
DIRSTACK=${DIRSTACK#* }
cd ${DIRSTACK%% *}
print "$PWD"
}
seq() {
local I=$1
while [ $2 != $I ]; do
print -n "$I "
I=$(( $I + 1 ))
done;
print "$2"
}
calc() {
perl -e 'print eval(join("", @ARGV)) . "\n";' $@
}
dir() {
ls -l | awk '{ if ( substr($1,1,1)== "d") {print}}'
}
epoch() {
perl -e "print scalar(localtime($1)) . \"\n\""
}
sshdel() {
perl -i -n -e "print unless (\$. == $1)" ~/.ssh/known_hosts;
}
svnadd() {
svn status | grep '\?' | awk '{print $2}'| xargs svn add
}
rot13 () {
tr "[a-m][n-z][A-M][N-Z]" "[n-z][a-m][N-Z][A-M]"
}
shuffle() {
RANDOM=`date +%s`
(
while IFS= read -r i; do
echo $RANDOM$RANDOM "$i";
done
) | sort | sed 's/^[0-9]* //'
}
alias xyzzy="echo Nothing happens."
alias mac2unix="tr '\r' '\n'"
alias dos2unix="tr -d '\r'"
alias sudo='sudo env PATH=$PATH' # Work around sudo built --with-secure-path
alias cal='cal -3'
alias l="ls -lrt"
alias hd='od -Ax -tx1z -v'
alias realpath='readlink -f'
ulimit -c unlimited
alias man=vman
vman() {
if [ $# -eq 0 ]; then
/usr/bin/man
elif [ $# -eq 2 ]; then
/usr/bin/man $1 $2 | col -b | $EDITOR -Rc 'set ft=man nomod nolist' -
elif whatis $* ; then
/usr/bin/man $* | col -b | $EDITOR -Rc 'set ft=man nomod nolist' -
fi
}
export PATH VISUAL EDITOR SVN_SSH HISTFILE CVS_RSH HOSTNAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment