Linux, Unix, /etc

Danger Will Robinson! You are now entering a condescending Unix user zone!
Sponsored links (requires javascript):

My .kshrc

# Commands after this case statement will be run only by interactive shells
# We don't need any of the stuff in here if we are running a shell script,
# so lets not go through it all unless we need to.
case $- in
	*i*) ;;
	*) return 0;;
esac
#

# hitting tab in pdksh completes file and command names.  Invaluable.
set -o vi-tabcomplete

# I only want to ignore eof on login shells 
case $- in
	*l*) set -o ignoreeof ;;
	*) ;;
esac

# I use screen, which sets TERM to "screen".  But most programs work better
# with TERM of "linux".  So...
case $TERM in
	screen) export TERM=linux ;;
esac

SIZE=`stty size`
ROWS=`echo $SIZE |  awk '{print $1}'`
COLUMNS=`echo $SIZE |  awk '{print $2}'`
export SCRN=`expr $ROWS - 1`

# tty stuff
alias cls='clear'
alias fix='/sbin/setterm -default;clear'

# screen stuff
alias sd='screen -d'
alias sr='screen -r -A -O'
alias sl='screen -list'

# mail stuff
alias scan="scan ${1:—form scan.new}"
alias sent='scan -form scan.sent +sent ${1:-last:$SCRN}'
alias recv='2>/dev/null scan +inbox'
alias drafts='2>/dev/null scansent +drafts'
alias pack='folder -pack'
alias work='vi `cat .list`'
alias play='2>/dev/null scan +play'
alias spam='2>/dev/null scan +spam last:$SCRN'
alias scans='scansent +ltrs/sent/misc last:$SCRN'
alias scanr='scan +ltrs//misc last:$SCRN'
sn()
{
	show -noshowproc $@ | less
}

# editing stuff
alias vi='vi -F'
alias va="vi + $HOME/Mail/.mh_aliases"
alias vb="vi + $HOME/.bookmarks.html"
alias vc="vi + $HOME/.calendar"
# this shell function could also be written as a script, of course, but
# it's here partly to show just how much you can do using functions — 
# most anything you can do in a script, actually.
# All it does is open the editor (I've hardcoded vi, but $EDITOR could be
# in there of course) on one of the draft e-mail messages in my MH drafts
# folder.
vd()
{
	case $1 in
	"");;
	last) vi $(ls $HOME/Mail/drafts/[1-9]*|sort -t '/' +5 -n|tail -1) ;;
	first) vi $(ls $HOME/Mail/drafts/[1-9]*|sort -t '/' +5 -n|head -1) ;;
	cur) vi $HOME/Mail/drafts/$(scan +drafts cur|awk '{print $1}'|sed 's/+//') ;;
	[0-9]*) vi $HOME/Mail/drafts/$1;;
	*) echo 'vd: usage: vd [first|last|<msg-nr.>]';; 
	esac
	echo $1
}
alias vj="vi + $HOME/writing/journals/journal.current"
alias vjn="(echo;echo;echo \`jdate\`;echo) >> $HOME/writing/journals/journal.current; $EDITOR + $HOME/writing/journals/journal.current"
alias vk="vi $HOME/.kshrc"
alias vl="vi + $HOME/logs/my-linux-journal"
alias vln="(echo;echo;echo \`jdate\`;echo) >> $HOME/logs/my-linux-journal; $EDITOR + $HOME/logs/my-linux-journal"
alias vm="vi $HOME/.procmailrc"
alias vn="vi + $HOME/notes"
alias vp="vi $HOME/.profile"
alias vt="vi $HOME/todo"
alias vv="vi + $HOME/.exrc"
alias ce='crontab -e'
alias cl='crontab -l'
alias emacs='emacs -nw'

# file management stuff
alias ls='ls -F'
# replaced by shell script
#alias la="ls -tr1 $HOME/articles/wip|egrep -v 'RCS|html-skel'"
alias le='ls -tr $HOME/writing/essays/wip'
alias lf='ls -Ftr|grep /|grep -v RCS'
alias cx="chmod +x $*"
alias pg=$PAGER
alias zpg="z$PAGER"
alias du='du -L'
alias pt='printtxt'
alias wcl='wc -l'
alias wcw='wc -w'
alias wcc='wc -c'
alias back='cd $OLDPWD'
export STORE=/tmp/
alias words='wc -w `la`|sort -n'

#printing stuff
alias lpr='lpr -h'

# chess stuff
alias gnuchess-blitz='xboard -tc 5 -mps 60'
alias gnuchess-quick='xboard -tc 30 -mps 60'
alias gnuchess-tourney='xboard -tc 150 -mps 40'

# miscellaneous
alias indent='indent -kr'
alias sc='sc -n -R'
alias fixtty='reset;stty sane'
alias minicom='minicom -m'
alias ustime='tm US/Eastern US/Central US/Mountain US/Pacific'
alias autime='tm Australia/West Australia/Queensland'
alias bc="bc -q $HOME/.bcrc"
alias pr='pr -l 65'
alias vplay='vplay -S -q'
alias entry="sc $HOME/accounts/home/`date +%Y`.sc"
alias lc='lastcall'
alias ca='calc'
alias wt='whattime'
alias edt='wt Eastern'
alias pdt='wt Pacific'
alias grep='egrep'
alias fi='finger'
alias top='(export TERM=linux;/usr/bin/top)'

#net stuff
alias netstat='netstat -tu'
alias grex="telnet grex.cyberspace.org"

alias a='ve $HOME/lib/phonebook'
# makes a job run in the background.  If you use ^Z to put a job in the
# background, it halts, so this is handy to get it started again.  OK, 
# so all it does is save a few keystrokes!
b()
{
    bg %$1
}
alias c='cls'
alias d='drafts'
alias e=$EDITOR
# a companion to b(), this brings a job to the foreground again.  I find it
# rather friendlier than fg, the shell built-in it replaces.
f()
{
    case $1 in
	0) job=1;;
	*) job=$1;;
    esac
    fg %$1
}
#alias g=
#alias h=
#alias i=
alias j='jobs'
# this is something that doesn't *quite* work.  What I wanted to do was give
# the list of jobs in an interactive prompt, but it doesn't work like that.
# Don't know why!
k()
{
case $1 in
"") echo "must give job number";;
*)
    list=$(jobs | awk -v var=$1 '/var/{print $0}')
    echo "kill $list?"
    read answer
    case $answer in
    [Yy]*) kill %$1;;
    esac
esac
}
#alias l='less'
l()
{
ls -al $1 | more
}
alias m='mount'
alias n='next'
alias o='comp'
alias p='prev'
alias q='/usr/lib/sendmail -q &'
alias r=recv
alias s='show'
alias t=telnet
alias u='uptime'
alias v='vi'
#NB: w=/usr/bin/w
#alias x=
#alias y=
#alias z=

twep()
{
    kill -9 ${1:?need process number for termination with extreme prejudice}
}

#functions to implement a simple manual directory stack
# I did this for the hell of it — I never use them.
# I think they are available as built-ins to ksh93.
dirindex=0
push()
{
dirindex=$((dirindex+1))
dirstack[$dirindex]=$PWD
}
pop()
{
if [ $dirindex -eq 0 ]
then
	echo stack empty
else
	cd ${dirstack[$dirindex]}
	dirindex=$((dirindex-1))
fi
}


[back to Linux, Unix, /etc]



Copyright © 1995-2007 Paul Dunne,

Sponsored links (requires javascript):