|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /usr/share/doc/bash-3.2/functions/ |
Upload File : |
# From: Seth Chaiklin <psykseth@aau.dk>
# To: chet@ins.CWRU.Edu
# Subject: bash functions (sorta)
#
# keep:
# usage: keep program
# declare the a program should be "kept". i.e. try to fg a stopped one
# and only when that fails start a fresh program.
#
keep()
{
case $# in
1|2) ;;
*) echo "usage: keep [alias] program" 1>&2 ; return 1;;
esac
# progname
pn=${1##*/}
# set up an alias for the kept program
if [ $# = 1 ]; then
alias "$pn=fg $1 2>/dev/null || $1"
else
alias "$1=fg $2 2>/dev/null || $2"
fi
}
#
# unkeep:
# usage: unkeep program
# unset the alias set up by the keep function
#
unkeep()
{
if [ $# != 1 ]; then
echo "usage: unkeep program"
return 2
fi
# unset the alias for the kept program
unalias "${1##*/}"
}
#
# kept:
# lists all kept programs in 'alias: program' form
#
kept()
{
alias | grep "fg.*2>" | sed "s/alias \(.*\)='fg.*||\(.*\)'$/\1:\2/"
}
# some things that should be kept
#keep /usr/local/bin/emacs
#keep e ${EDITOR:-/usr/local/bin/emacs}
#keep edit ${EDITOR:-/usr/local/bin/emacs}
#keep /usr/local/bin/emm