#vanquirius's bashrc ;-) #### ka0ttic's bashrc ######################################################### # Quite large bashrc, as I use the same one for all my boxen. # Some of this stuff was stolen/hacked from Ciaran McCreesh's bashrc at # http://dev.gentoo.org/~ciaranm/configs/bashrc # # Last updated: Wed 23 Mar 2005 08:23:01 AM EST # ############################################################################### [[ $- != *i* ]] && return set -P set -o notify shopt -s cdspell checkwinsize cmdhist expand_aliases checkhash extglob shopt -u mailwarn umask 0022 export LANG="en_US.utf8" export LC_CTYPE="pt_BR.ISO-8859-1" export HOSTNAME=$(hostname -s) export UNAME=$(uname -s) export CVSDIR=$HOME/cvs export CDPATH=".:~:~/code:~/cvs:~/cvs/gentoo-x86" export GENTOO_CVS=vanquirius@cvs.gentoo.org:/var/cvsroot unset MAIL MAILPATH export HISTIGNORE="&:ls:cd" export HISTCONTROL=ignoreboth export HISTFILE=/dev/null [[ -z "${RUNLEVEL}" ]] && \ export RUNLEVEL=$(sudo cat /var/lib/init.d/softlevel 2>/dev/null) # prefix; vanilla BSD uses /usr/local for all third party software PREFIX="/usr" [[ "$UNAME" == "FreeBSD" && ! -e /etc/gentoo-release ]] && PREFIX="/usr/local" # PATH [[ -n "${PATH/*${HOME}\/bin:*}" ]] && PATH="$HOME/bin:$PATH" [[ -n "${PATH/*\/usr\/local\/bin:*}" ]] && PATH="/usr/local/bin:$PATH" export PATH # PAGER if [[ -x $PREFIX/bin/most ]] ; then PAGER=most alias less="most" elif [[ -x /usr/bin/less ]] ; then PAGER=less else PAGER=more alias less="more" fi export PAGER # EDITOR EDITOR=/usr/bin/nano export EDITOR alias nano="nano -w" #GCC alias gcc4="gcc-config 6; source /etc/profile; sb" alias gcc3="gcc-config 1; source /etc/profile; sb" #du, df alias du="du -hs" alias df="df -h" if [[ "${TERM}" == "rxvt-unicode" ]] ; then export TERMTYPE="256" elif [[ "${TERM}" != "dumb" ]] ; then export TERMTYPE="16" else export TERMTYPE="" fi select_by_term() { if [[ "${TERMTYPE}" == "256" ]] ; then echo -n "$1" elif [[ "${TERMTYPE}" == "16" ]] ; then echo -n "$2" else echo -n "$3" fi } # OS-specific variables/aliases case $UNAME in "Linux") eval $(dircolors -b /etc/DIR_COLORS) alias ls="ls --color=always --ignore-backups" alias ll="ls -hl" [[ -f /etc/profile.d/bash-completion ]] && . /etc/profile.d/bash-completion ;; esac export FIGNORE='~' case $TERM in xterm*|rxvt|Eterm|eterm|rxvt-unicode) PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"' ;; screen) PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"' ;; esac set_prompt() { local NO_COLOR="\[\033[00m\]" [[ -z "$COLOR_ONE" ]] && COLOR_ONE="\[\033[01;32m\]" # default green [[ -z "$COLOR_TWO" ]] && COLOR_TWO="\[\033[01;34m\]" # default blue [[ -z "$COLOR_THREE" ]] && COLOR_THREE="\[\033[01;30m\]" # default gray export PS1="${COLOR_ONE}-${COLOR_TWO}-${COLOR_THREE}(${COLOR_ONE}\u@${COLOR_TWO}\h\ ${COLOR_THREE})${COLOR_ONE}-${COLOR_THREE}(${COLOR_ONE}\$?${COLOR_THREE})${COLOR_ONE}-\ ${COLOR_TWO}-${COLOR_THREE}(${COLOR_TWO}\w${COLOR_THREE})${COLOR_ONE}-${COLOR_TWO}-\n\ ${COLOR_ONE}>${COLOR_TWO}>${COLOR_ONE}>${NO_COLOR} " export PS2="${COLOR_THREE}>${NO_COLOR} " } # host-specific stuff case $HOSTNAME in *) PS1="\[\033[01;32m\]\u@\h \[\033[01;34m\]\w \$ \[\033[00m\]" ;; esac ############################################################################### # aliases and other app-specific settings ############################################################################### alias cl="clear" alias grep="grep -n --color=auto" alias diff="diff --exclude=*~ -Naur" alias sb="source ~/.bashrc" alias psall="ps fax -o pid,ppid,user,%cpu,%mem,rss,time,comm" alias fbg="fbsetbg -f" # display ALL setuid/setgid files on the system alias find-suidgid="find / -type f \( -perm -004000 -o -perm -002000 \) \ -exec ls -1g {} \; 2>/dev/null" # display ALL world/group writable files alias find-ww-files="find / -type f \( -perm -2 -o -perm -20 \) \ -exec ls -lg {} \; 2>/dev/null" # display ALL world/group writable dirs alias find-ww-dirs="find / -type d \( -perm -2 -o -perm -20 \) \ -exec ls -ldg {} \; 2>/dev/null" if [[ -x $PREFIX/bin/irssi && -x $PREFIX/bin/screen ]] ; then alias irssi="screen -Aa -t irssi -S irssi -T xterm irssi" fi if [[ -x $PREFIX/bin/screen ]] ; then alias screen="screen -Aa -T xterm" fi if [[ -x $PREFIX/bin/devtodo || -x $PREFIX/bin/ondir ]] ; then alias ta="devtodo all" alias an="annodir" export TODO_OPTS="--timeout" cd() { local rv builtin cd "$@" rv=$? if [[ ${rv} -eq 0 ]] ; then if [[ -x $PREFIX/bin/devtodo ]] ; then [[ -r .todo ]] && devtodo ${TODO_OPTS} fi #if [[ -x $PREFIX/bin/annodir ]] ; then # [[ -r .annodir ]] && annodir ${ANNODIR_OPTS} #fi if [[ -x $PREFIX/bin/ondir ]] ; then eval $(ondir "${OLDPWD}" "${PWD}") fi true fi return ${rv} } fi if [[ -x $PREFIX/bin/colordiff ]] ; then alias cdiff="colordiff --exclude=*~" fi if [[ ! -x $PREFIX/bin/nc && -x $PREFIX/bin/netcat ]] ; then alias nc="netcat" fi if [[ -x $PREFIX/bin/fetchmail && $UID -ne 0 ]] ; then alias fetchmail="sudo $PREFIX/bin/fetchmail" fi if [[ -x $PREFIX/bin/exuberant-ctags ]] ; then alias ctags="exuberant-ctags" fi if [[ -x $PREFIX/bin/dog ]] ; then alias cat="dog" # haha fi if [[ -x $PREFIX/bin/dmalloc ]] ; then function dmalloc { eval $(command dmalloc -b $*) ; } fi if [[ -x /usr/bin/cvs ]] ; then [[ -x $PREFIX/bin/colorcvs ]] && cvs="colorcvs" || cvs="cvs" alias cu="$cvs up" alias co="$cvs co" cvsdiff() { $cvs diff "$@" | colordiff | /usr/bin/less -R } cvslog() { if [[ -x $PREFIX/bin/source-highlight && -x $PREFIX/bin/cvs2cl ]]; then cvs2cl --stdout "$@" | source-highlight -s changelog -f esc \ | /usr/bin/less -R elif [[ -x $PREFIX/bin/cvs2cl ]] ; then cvs2cl --stdout "$@" | $PAGER else $cvs log | $PAGER fi } fi if [[ -x $PREFIX/bin/svn ]] ; then alias svns="svn status --verbose" alias svnd="svn diff --diff-cmd /usr/bin/colordiff -x -u" fi # gentoo-specific variables/aliases if [[ -e /etc/gentoo-release ]]; then export CVSROOT="${GENTOO_CVS}" export ECHANGELOG_USER="Marcelo Goes " alias accept="ACCEPT_KEYWORDS='~x86'" alias acceptm="ACCEPT_KEYWORDS='-~x86'" alias nomirror="GENTOO_MIRRORS='' RESTRICT=nomirror" alias debug="USE='debug' FEATURES='nostrip' CFLAGS='-ggdb3' CXXFLAGS='-ggdb3'" alias maketest="USE='test debug' FEATURES='test nostrip' CFLAGS='-ggdb3' CXXFLAGS='-ggdb3'" alias keepwork="FEATURES='keepwork'" alias show_distfiles="ssh toucan ls -lh /space/distfiles-local" function show_alias() { ssh toucan cat /var/mail/alias/$1; } # CVS alias cpd="PORTDIR_OVERLAY=\"$CVSDIR/gentoo-x86\"" function cpde() { PORTDIR_OVERLAY="$CVSDIR/gentoo-x86" ebuild $1 digest; } function cpde_all() { for ebuild in *.ebuild ; do cpde $ebuild ; done ; } if [[ $UID -ne 0 ]]; then alias emerge="sudo /usr/bin/emerge" if [[ -x /usr/sbin/esync ]] ; then alias esync="sudo /usr/sbin/esync" else alias esync="emerge sync" fi alias gsync="SYNC=rsync://rsync.gentoo.org/gentoo-portage sudo /usr/bin/emerge sync && sudo /usr/bin/emerge -uDF world" alias etc-update="sudo /usr/sbin/etc-update" alias dispatch-conf="sudo /usr/sbin/dispatch-conf" alias rc-update="sudo /sbin/rc-update" alias gcc-config="sudo /usr/bin/gcc-config" fi function ekw() { ekeyword $* ; } # echangelog alias echl="echangelog" alias echlvb="echangelog 'Version bump.'" alias echlms="echangelog 'Marked stable on x86.'" # repoman alias reps="repoman scan" alias repf="repoman full" alias repc="repoman commit -m" alias repcvb="repc 'Version bump.'" alias repcms="repc 'Stable on x86.'" alias gmetagen="gvim metadata.xml +NewMetadata" [[ -x /usr/bin/metagen ]] && alias metagen="metagen -f" [[ -x /usr/bin/splat ]] && alias splat="splat -c" if [[ -x /usr/bin/genlop ]] ; then alias lastemerges="genlop -l | tail -n11" alias lastsync="genlop -r | tail -n2" fi alias ehelp="man 5 ebuild" else [[ -n "${LOCAL_CVS}" ]] && export CVSROOT="${LOCAL_CVS}" fi ############################################################################### # misc functions ############################################################################### echo1() { echo "$1"; } # echo command ($1) and then run command, bailing if it fails dothis() { echo " * Running $*" if ! $* ; then echo "Yowzers! something's wrong." return 1 fi } # check if box is ping-able isalive() { ping -r -c1 -W1 $1 &>/dev/null ; } # open manual page inside gvim vman() { man $* | col -b | gvim -c 'set ft=man nomod nolist' - ; } # run [g]vim's :TOhtml from command line tohtml() { local x v # use vim if -v is specified [[ "$1" == "-v" ]] && { v="vim" ; shift ; } for x in $@ ; do ${v:-gvim} +TOhtml "+w! ${x##*/}.html" +q! +q! +q ${x} done } # open a manual page and run vim's :TOhtml man2html() { local x for x in $@ ; do man ${x} | col -b | gvim -c 'set ft=man nomod nolist' \ '+let html_number_lines=0' +TOhtml "+w! ${x}.html" +q! +q! +q - done } # source hilite - run source-highlight piped to less shl() { if [ $COLUMNS -gt 80 ] ; then source-highlight -s cpp -f esc -i "$1" | nl -ba | $(which less) -R else source-highlight -s cpp -f esc -i "$1" | $(which less) -R fi } src2html() { local file [[ ! -d html ]] && mkdir html || return 1 for file in * ; do [[ -r $file ]] && code2html -t 4 -N -o html-dark $file html/$file.html done } mcd() { mkdir -p $1 && cd $1; } # quiet cd qcd() { builtin cd "$@" &>/dev/null; } # given a file or directory in a cvs/svn checkout, remove it and # cvs/svn update reup() { local oldpwd=$PWD rm -fr $1 if [[ -d "CVS" ]] ; then cvs up $1 elif [[ -d "${1%/*}/CVS" ]] ; then builtin cd ${1%/*} cvs up ${1##*/} builtin cd $oldpwd elif [[ -d '.svn' ]] ; then svn up $1 elif [[ -d "${1%/*}/.svn" ]] ; then builtin cd ${1%/*} svn up ${1##*/} builtin cd $oldpwd else echo "hrm.. doesnt seem to be in a cvs or svn repository!" return 1 fi } utc() { # show current time in UTC if [[ -z "$1" ]] ; then date -u # show localtime equiv of $1 else date -d "$1 utc" | sed -e "s/^.* \(.*:.*\) .*$/\1/" fi } # run $2 for each package specified (in cat/pkg format) in file $1 foreach_pkg() { local p for p in $(< $1) ; do echo -e "${p}\n$($2 ${p})\n" done } autogen() { local config_opts libtoolize --force --copy --automake rm -f config.cache dothis aclocal -I . ${ACLOCAL_FLAGS} || return 1 dothis autoheader || return 1 dothis automake -a || return 1 dothis autoconf || return 1 [[ -n "${EXTRA_ECONF}" ]] && config_opts="${config_opts} ${EXTRA_ECONF}" [[ -z "${NDEBUG}" ]] && config_opts="${config_opts} --enable-debug=yes" case "$(uname -s)" in Linux) if grep -q CHOST /etc/make.conf ; then CHOST=$(grep CHOST /etc/make.conf | sed -e 's/^.*"\(.*\)".*$/\1/') else CHOST=$(portageq envvar CHOST) fi config_opts="--prefix=/usr --host=${CHOST} --mandir=/usr/share/man \ --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc \ --localstatedir=/var/lib --includedir=/usr/include --libdir=/usr/lib ${config_opts}" ;; # let autotools pick default (freebsd uses normal defaults) *) ;; esac if which configure 2>/dev/null ; then echo -e " * Running configure ${config_opts}\n" $(which configure) ${config_opts} || return 1 elif [[ -x ./configure ]] ; then echo -e " * Running ./configure ${config_opts}\n" ./configure ${config_opts} || return 1 else echo "Hrm... configure doesn't exist or isn't executable!" exit 1 fi } echo_all_colors() { local x for (( x = 0 ; x <= 90 ; x++ )) ; do echo -e "\033[00m${x}m: \033[38;5;${x}mlala" done } check_agent() { ls -lh ${GPG_AGENT_INFO%%:*} } ############################################################################### # Gentoo-specific functions ; most of these were written (or are based on # functions written) by Ciaran McCreesh ############################################################################### if [[ -e /etc/gentoo-release ]] ; then explainuse() { local portdir=$(eportdir) sed -ne "s,^\([^ ]*:\)\?$1 - ,,p" \ ${portdir}/profiles/use.desc \ ${portdir}/profiles/use.local.desc } upload_distfile() { local x if [[ -z "$1" ]]; then echo "upload what?" return 1 fi if [[ ! -e $1 ]]; then echo "$1 doesn't exist." return 1 fi for x in $@ ; do scp $x vanquirius@dev.gentoo.org:/space/distfiles-local/ ; done } metagrep() { local x y portdir=$(eportdir) builtin cd $portdir for x in *-* ; do [[ -d "${x}" ]] || continue for y in $(grep -l "$*" ${x}/*/metadata.xml) ; do echo "${y%/*}" ; done done builtin cd $OLDPWD } find_missing_metadatas() { local x portdir=$(eportdir) for x in ${portdir}/*-*/* ; do [[ "${x}" != */CVS && ! -e ${x}/metadata.xml ]] && echo "${x#${portdir}/}" done } # find either a cvs co of gentoo's portage module or the portage directory, and # echo the result. eportdir() { # does fast cache magic. portageq in particular is really slow... this makes # subsequent calls to eportdir() pretty much instantaneous, as opposed to # taking several seconds. if [[ -d ${HOME}/gentoo-x86 ]] ; then eval "eportdir() { echo ${HOME}/gentoo-x86 ; }" eportdir $* elif [[ -d ${CVSDIR}/gentoo-x86 ]] ; then eval "eportdir() { echo ${HOME}/cvs/gentoo-x86 ; }" eportdir $* else eval "eportdir() { echo `portageq portdir` ; }" eportdir $* fi } # find a given ebuild. based upon code by agriffis. does some fancy prediction, # so it will find categories if necessary (eg efind sparc-dev-sources will find # sys-kernel/sparc-dev-sources, and does partial name matching). prints the # result in the form category/package . efind() { local efinddir cat pkg efinddir=$(eportdir) case $1 in *-*/*) pkg=${1##*/} cat=${1%/*} ;; ?*) pkg=${1} cat=$(echo1 ${efinddir}/*-*/${pkg}/*.ebuild) [[ -f $cat ]] || cat=$(echo1 ${efinddir}/*-*/${pkg}*/*.ebuild) [[ -f $cat ]] || cat=$(echo1 ${efinddir}/*-*/*${pkg}/*.ebuild) [[ -f $cat ]] || cat=$(echo1 ${efinddir}/*-*/*${pkg}*/*.ebuild) [[ -f $cat ]] || return 1 pkg=${cat%/*} pkg=${pkg##*/} cat=${cat#${efinddir}/} cat=${cat%%/*} ;; esac echo ${cat}/${pkg} } # guesses who is to blame for a given package. uses metadata.xml if it's # available. if not, it will try to use cvs log to determine who commited the # ebuilds (only if a cvs co is available, of course...) ewho() { local pc d metadata f pc=$(efind $*) d=$(eportdir) f=0 if [[ -z "$pc" ]] ; then echo "nothing found for $*" return 1 fi echo -e "\033[0;34m${pc}\033[0m:" metadata="${d}/${pc}/metadata.xml" if [[ -f "${metadata}" ]] ; then sed -ne 's,^.*\([^<]*\).*, herd: \1,p' \ "${metadata}" sed -ne 's,^.*\([^<]*\)@[^<]*.*, dev: \1,p' \ "${metadata}" f=1 elif [[ -d ${d}/${pc}/CVS ]] ; then if [[ ${RUNLEVEL} != "work" ]] ; then pushd ${d}/${pc} > /dev/null for e in *.ebuild ; do echo -n "${e}: " cvs log ${e} | sed -e '1,/^revision 1\.1$/d' | sed -e '2,$d' \ -e "s-^.*author: --" -e 's-;.*--' done popd > /dev/null f=1 else echo "Cannot access cvs.gentoo.org!" fi fi if [[ $f -eq 0 ]] ; then echo "Nothing found, so blame ciaranm (who blames seemant)" return 1 fi return 0 } # cd to an package's directory. ecd() { local package=$(efind $1) portdir=$(eportdir) if [[ -z "${package}" ]] ; then echo "nothing found for $1" return 1 fi [[ -d ${portdir}/${package} ]] && builtin cd ${portdir}/${package} } # ls a package's directory els() { local package=$(efind $1) portdir=$(eportdir) if [[ -z "${package}" ]] ; then echo "nothing found for $1" return 1 fi # show hidden files but not . or .. [[ -d ${portdir}/${package} ]] && \ ls -lha --color=none ${portdir}/${package} | grep -v '\.$' } # show a package's DESCRIPTION edesc() { local package portdir color=1 if [[ -z "$1" ]] ; then if ! ls *.ebuild &>/dev/null ; then echo "usage: edesc " return 1 else package=$(basename ${PWD%%$(basename $PWD)})/$(basename $PWD) fi elif [[ $1 == "-nc" ]] ; then color=0 package="$2" else package="$1" fi package=$(efind ${package}) if [[ -z "${package}" ]] ; then echo "Unable to find $1" return 1 fi portdir=$(eportdir) if [[ ${color} -eq 1 ]] ; then echo -ne "\033[0;34m${package}\033[0;0m: " else echo -n "${package}: " fi cat ${portdir}/${package}/*.ebuild \ | sed -ne 's-^DESCRIPTION="\(.*\)".*-\1-1p' | sort | uniq } # run edesc on every package in a category edesc_cat() { local cat pkg portdir=$(eportdir) if [[ -z "${1}" ]]; then if [[ $PWD == *${portdir}* ]] ; then edesc_cat ${PWD/${portdir}\/} return $? else echo "which category?" return 1 fi else cat=$1 fi if [[ ! -d ${portdir}/${cat} ]]; then echo "${cat} doesn't seem to be a valid category." return 1 fi for pkg in ${portdir}/${cat}/* ; do if [[ -d ${pkg} ]] && [[ ${pkg##*/} != "CVS" ]] ; then edesc ${pkg##*/} fi done } # show a package's HOMEPAGE ewww() { local package portdir=$(eportdir) if [[ -z "${1}" ]]; then echo -ne "\033[0;34m${PWD##${portdir}/}\033[0;0m: " cat *.ebuild | \ sed -ne 's-^HOMEPAGE="\(.*\)".*-\1-1p' || return 1 return 0 fi package=$(efind ${1}) if [[ -z ${package} ]]; then echo "Unable to find ${1}" return 1 fi echo -ne "\033[0;34m${package}\033[0;0m: " cat ${portdir}/${package}/*.ebuild | \ sed -n -e 's-^HOMEPAGE="\(.*\)".*-\1-1p' | sort | uniq } # ecl - display ebuild changelog # defaults to using vim (thanks to ciaranm's pretty changelog syntax ;p) # or $PAGER if you are a weirdo and don't have vim ecl() { local viewer=$(/usr/bin/which vim 2>/dev/null) portdir=$(eportdir) viewer=${viewer:-${PAGER}} if [[ -z "${1}" ]]; then # view any ChangeLog not necessarily one for an ebuild if [[ -e ChangeLog ]]; then ${viewer} ChangeLog return $? else echo No ChangeLog found. return 1 fi else local name=$(efind ${1}) [[ -z ${name} ]] && name=${1} if [[ -d "${portdir}/${name}" ]]; then if [[ -e "${portdir}/${name}/ChangeLog" ]]; then ${viewer} "${portdir}/${name}/ChangeLog" else echo No ChangeLog found for ${name}. return 1 fi else echo ${name} not found. return 1 fi fi } # modified version of ciaranm's eshowkw() ekg() { local x y e v p a k local archs pkgdir portdir=$(eportdir) if [[ -z "$1" ]] ; then if ! ls *.ebuild &>/dev/null ; then echo "No ebuilds in PWD." return 1 fi else local r=$(efind $1) if [[ -z "$r" ]] ; then echo "Nothing found for $1" return 1 else pkgdir="${portdir}/${r}/" fi fi archs=$(< ${portdir}/profiles/arch.list) for x in 1 2 3 4 5 ; do printf "%-18s| " "" for a in ${archs} ; do printf "%1s%1s " "${a:$((${x} - 1)):1}" "${a:$((5 + (${x} - 1))):1}" done echo "" done printf "%-18s+" "------------------" for a in ${archs} ; do printf "%3s" "---" done echo "" for e in ${pkgdir}*.ebuild ; do v=${e##*/} ; v=${e%%.ebuild} p=${e%-[0-9]*} ; v=${v##${p}-} printf "%-18s| " ${v} for a in ${archs} ; do k=$(cat "${e}" | sed -ne "s/^KEYWORDS=.*\([-~ \"]${a}[^a-zA-Z0-9\-]\).*/\1/1p") case "$k" in ~*) echo -ne "\033[01;33m~ " ;; -*) echo -ne "\033[01;31m- " ;; ?*) echo -ne "\033[01;34m+ " ;; *) grep 'KEYWORDS=.*-\*' ${e} > /dev/null \ && printf "\033[01;31m* " \ || printf " " ;; esac done echo -e "\033[00m" done } esup() { [[ -z "$1" ]] && return 1 local possible_hosts="bedlam zeus" local host=${possible_hosts/${HOSTNAME}} builtin cd ${HOME} for dir in "${@}"; do local rsync_opts="-a --progress" [[ -d "${CVSDIR}/${dir}" ]] && rsync_opts="${rsync_opts} --delete" rsync ${rsync_opts} ${host}:${CVSDIR}/${dir} ${CVSDIR} done builtin cd ${OLDPWD} } grep_portage() { local regex="$1" oldpwd="$PWD" portdir=$(eportdir) local pkg ebuild [ -z $1 ] && echo "grep for what?" && return 1 builtin cd $portdir || return 1 for ebuild in *-*/*/*.ebuild ; do if grep -P "$@" $ebuild &>/dev/null ; then echo -n "\033[00;34m${ebuild##*/}\033[00m: " grep -Ph "$@" $ebuild fi done builtin cd $oldpwd } # for init.d scripts svcs() { local svc [[ -z $1 ]] && echo "usage: svcs " && return 1 for svc in "$@"; do sudo /etc/init.d/$svc start done } svcz() { local svc [[ -z $1 ]] && echo "usage: svcz " && return 1 for svc in "$@"; do sudo /etc/init.d/$svc zap done } svce() { local svc [[ -z "${1}" ]] && echo "usage: svce " && return 1 for svc in "$@"; do sudo /etc/init.d/$svc stop done } svcr() { local svc [[ -z "${1}" ]] && echo "usage: svcr " && return 1 for svc in "$@"; do sudo /etc/init.d/$svc restart done } svcstat() { local svc [[ -z "${1}" ]] && echo "usage: svcstat " && return 1 for svc in "$@"; do sudo /etc/init.d/$svc status done } # completions for our functions complete -F _emerge edesc ewho efind ecl ekg ecd ewww complete -F _ekeyword ekw complete -W "$(for x in ${CVSDIR}/* ; do echo ${x##*/} ; done)" esup complete -W "$(for x in /etc/init.d/*[^~]; do echo ${x##*/}; done)" \ svcs svce svcz svcr svcstat complete -W "$(for x in $(eportdir)/*-*; do echo ${x##*/}; done)" edesc_cat fi # [ -e /etc/gentoo-release ] # load any additional stuff if [[ -d ~/.bash ]]; then for file in ~/.bash/* ; do [[ -f $file ]] && source $file done fi return 0 # vim: set tw=80 sw=4 ts=4 noet : # eix [ -f /etc/profile.d/bash-completion ] && . /etc/profile.d/bash-completion alias esearch="eix"