Bash

bashrc

   1 umask 0002
   2 
   3 export EDITOR="emacs"
   4 export HISTSIZE=100000
   5 export history_control=ignoredups
   6 export MANPAGER=less
   7 
   8 unset LS_COLORS
   9 unset TZ
  10 
  11 # Test if shell is interactive
  12 case "$-" in
  13   *i*)
  14     # Options
  15     alias grep='grep --color=auto'
  16     alias hg='/appl/mercurial/hg'
  17     alias nano='nano -w'
  18     # if [[ "${EUID}" == 0 ]] ; then
  19     #   alias ssh='ssh -CY'
  20     #   alias s="echo \"Executing su - $@\"; su - $@"
  21     # else
  22     #   alias ssh='ssh -ACY'
  23     # fi
  24     #alias wget='wget -c'
  25     #alias ping='ping -c10'
  26     alias ls='ls --color=auto'
  27     alias ll='ls -alrt --color'
  28     alias dire='ls -lrth'
  29     alias ..='cd ..'
  30     # Typos
  31     alias cd..='cd ..'
  32     alias xs='cd'
  33 
  34     # special hosts
  35     alias scgate='ssh scgate'
  36     alias schp01='ssh schp01'
  37     alias schp02='ssh schp02'
  38     alias schp03='ssh schp04'
  39     alias schp04='ssh schp04'
  40     
  41     # abbreviations
  42     alias ll='ls -alrt --color'
  43     alias e='echo -e'
  44     alias p='ps -AlFwww --forest'
  45 
  46     # Features and functions
  47     alias top='unset top_skip; for a in $(eval echo {1..${LINES}}); do top_skip="${top_skip}\n"; done; echo -e ${top_skip}; unset top_skip; top -H -n1000 -c'
  48     
  49     b(){
  50       unset NUMARGS NONNUMARGS
  51       for ARG in $@; do
  52         if [[ ${ARG} =~ ^[0-9]+$ ]]; then
  53           NUMARGS="${NUMARGS} ${ARG}"
  54         else
  55           [ "${ARG}" = "-m" ] && NONNUMARGS="${NONNUMARGS} -u all -a"
  56           NONNUMARGS="${NONNUMARGS} ${ARG}"
  57         fi
  58       done
  59       if echo "${NONNUMARGS}" | grep -vwq '\-l'; then
  60         NONNUMARGS="-w ${NONNUMARGS}"
  61       fi
  62       if [ "${NONNUMARGS##* }" = '-m' -a -x /opt/LSF/bin/bjobs ]; then
  63         # The last non-numeric argument is -m this can only be wrong
  64         # Therefore I use ${HOSTNAME} as additional argument if I am on a host where /opt/LSF/bin/bjobs is executable
  65         NONNUMARGS="${NONNUMARGS} ${HOSTNAME}"
  66       fi
  67       ARGS="${NONNUMARGS} ${NUMARGS}"
  68       if [ -x /opt/LSF/bin/bjobs ]; then
  69         /opt/LSF/bin/bjobs ${ARGS}
  70       else
  71         ssh scacc1 /opt/LSF/bin/bjobs ${ARGS}
  72       fi
  73       unset NONNUMARGS NUMARGS ARGS
  74     }
  75     
  76     mycat(){
  77       for FILE in $@; do
  78         if [ -r "${FILE}" ]; then
  79           if [ "$(awk 'BEGIN{l=0}; {l+=1}; END{print l}' ${FILE})" -gt "$((LINES-LINES/10))" ]; then
  80             less ${FILE}
  81           else
  82             cat ${FILE}
  83           fi
  84        else
  85          echo ERROR: File \""${FILE}"\" is not readable. 1>&2
  86        fi
  87       done 
  88     }
  89     
  90     # "cd" wrapper that interpretes its argument and extracts the directory automatically
  91     # It understands
  92     # - . dir dir/file host:dir host:dir/file user@host:dir user@host:dir/file
  93     c(){
  94       local arg
  95       arg="${1}"
  96       # Strip username
  97       if echo "${arg}" | grep -q '@' && finger $(echo "${arg}" | awk -F'@' '{print $1}') 2>&1 | grep -v ": no such user." 1>/dev/null; then
  98         arg=$(echo "${arg}" | cut -d'@' -f 2-)
  99       fi
 100       
 101       # Strip hostname
 102       if echo "${arg}" | grep -q ':' && f_ping $(echo "${arg}" | awk -F':' '{print $1}') 2>/dev/null; then
 103         arg=$(echo "${arg}" | cut -d':' -f 2-)
 104       fi
 105       
 106       # Tilde expansion
 107       if echo "${arg}" | grep -q '~'; then
 108         arg="$(eval ls -d ${arg} 2>/dev/null)"
 109       fi
 110 
 111       # Strip filename
 112       if [ -f "${arg}" ]; then
 113         arg="$(dirname "${arg}")"
 114       fi
 115       
 116       # Now it should be a directory in most cases
 117       if [ -d "${arg}" ]; then
 118         cd "${arg}"
 119       else
 120         cd $@
 121       fi
 122       return $?
 123     }
 124 
 125     d(){
 126       du -h --max-depth=1 $@
 127     }
 128     
 129     f(){
 130       local ARGS
 131       if [ $# -eq 0 ]; then
 132         ARGS="${USER}" 
 133       else
 134         ARGS="$@"
 135       fi
 136       finger ${ARGS} 2>&1 | grep -v ": no such user." || grep ${ARGS} /etc/passwd
 137     }
 138     
 139     alias l 2>/dev/null 1>&2 && unalias l
 140     l(){
 141       ls -alrt --color $@ | tail -n $((LINES-LINES/10))
 142     }
 143     
 144     n(){
 145       local NEDITFILES NEDITFILES NEDITWHICH
 146       local NEDIT=${NEDIT:=/applbin/nedit}
 147       [ -x ${NEDIT} ] || NEDIT="$(which nedit)"
 148       [ -x ${NEDIT} ] || NEDIT="/shared/appl/opensoft/Linux/nedit/bin/nedit"
 149       for NEDITARG in $@; do
 150         if [ -r "${NEDITARG}" ]; then
 151           NEDITFILES="${NEDITFILES} ${NEDITARG}"
 152         elif which ${NEDITARG} 1>/dev/null 2>&1; then
 153           NEDITFILES="${NEDITFILES} $(which ${NEDITARG})"
 154         else
 155           NEDITFILES="${NEDITFILES} ${NEDITARG}"
 156         fi
 157       done
 158       ${NEDIT} ${NEDITFILES} &
 159     }
 160     
 161     t(){
 162       tail -n $((LINES-LINES/10)) $@
 163     }
 164     
 165     str(){
 166       for a in $@; do 
 167         strace -p ${a} 2>&1 | head -n $((LINES-LINES/10))
 168       done
 169     }
 170     
 171     # Time format for debugging
 172     f_date(){
 173       date "+%F_%T"
 174     }
 175 
 176     # Funktion, die Keychain startet und SSH_AUTH_SOCK und SSH_AGENT_PID korrekt setzt
 177     f_keychain(){
 178       for KC in /usr/bin/keychain ${HOME}/bin/keychain; do
 179         if [ -x "${KC}" ]; then
 180           break
 181         fi
 182       done
 183       if [ -x "${KC}" ]; then
 184         for KEY in ${HOME}/.ssh/id_dsa ${HOME}/.ssh/id_rsa; do
 185           if [ -r "${KEY}" ];then
 186             eval $(${KC} $@ --lockwait 120 --attempts 10 --timeout 8928 -q --eval ${KEY})
 187           fi
 188         done
 189       fi
 190     }
 191     
 192     f_ping(){
 193       ping -c1 ${1} 1>/dev/null || ping -c2 ${1} 1>/dev/null || ping -c3 ${1} 1>/dev/null
 194     }
 195     
 196     f_bswitch_error_to_firstqueue(){
 197       if [ ${1} ]; then
 198         user=${1}
 199       else
 200         user=all
 201       fi
 202       for a in $(bjobs -q error -u ${user} | awk '{if ( $1 ~ /[0-9]/ && $3 ~/PEND/) {print $1}}'); do 
 203         bswitch $(bhist -l ${a} | gj -ofd=' ' -keys=firstqueue) ${a}
 204       done
 205       unset user
 206     }
 207     
 208     f_bswitch_from_user_if_ws_pings(){
 209      if [ "${1}" ]; then
 210        echo "using ${1} as DEAD_WORKSTATION"
 211        DEAD_WORKSTATION="${1}"
 212        shift
 213      else
 214        echo usage: f_bswitch_from_user_if_ws_pings DEAD_WORKSTATION AFFECTED_USER
 215        return 1
 216      fi
 217      if [ ${1} ]; then
 218        AFFECTED_USER="${1}"
 219        shift
 220      fi
 221      a=1
 222      until ping -c2 ${DEAD_WORKSTATION} >/dev/null 2>&1; do
 223        sleep ${a} && ((a++))
 224      done && f_bswitch_error_to_firstqueue ${AFFECTED_USER}
 225      unset DEAD_WORKSTATION AFFECTED_USER a
 226     }
 227     
 228     # GNU (bash) function from Gentoo (ebuild.sh)
 229     f_strip_duplicate_slashes() {
 230         if [[ -n $1 ]] ; then
 231                 local removed=$1
 232                 while [[ ${removed} == *//* ]] ; do
 233                         removed=${removed//\/\///}
 234                 done
 235                 echo ${removed}
 236         fi
 237     }
 238     
 239     bkill_hanging_job(){
 240       ts_of_youngest_file=0
 241       for a in *; do
 242         ts="$(date +%s --date="$(stat -L -c %y ${a})")" && [ "${ts}" -gt "${ts_of_youngest_file}" ] && ts_of_youngest_file=${ts}
 243       done
 244       age_of_youngest_file="$[($(date +%s)-${ts_of_youngest_file})]"
 245       if [ "${age_of_youngest_file}" -lt "$[5*60*60]" ]; then
 246         echo sleep $[$[5*60*60]-${age_of_youngest_file}+10]
 247       else
 248         /shared/appl/tools/beta/vwhpc_debug_job 1>&2
 249         if tail -n1 JOB_OUTPUT.1383924.Radth-Vect-coupling | grep -q 'Waiting for'; then
 250           echo bkill it
 251         fi
 252       fi
 253     }
 254 
 255     # GNU (bash) function from Gentoo (ebuild.sh)
 256     unpack() {
 257         local srcdir
 258         local x
 259         local y
 260         local myfail
 261         local tar_opts=""
 262         [ -z "$*" ] && die "Nothing passed to the 'unpack' command"
 263 
 264         for x in "$@"; do
 265                 vecho ">>> Unpacking ${x} to ${PWD}"
 266                 y=${x%.*}
 267                 y=${y##*.}
 268 
 269                 if [[ ${x} == "./"* ]] ; then
 270                         srcdir=""
 271                 elif [[ ${x} == ${DISTDIR%/}/* ]] ; then
 272                         die "Arguments to unpack() cannot begin with \${DISTDIR}."
 273                 elif [[ ${x} == "/"* ]] ; then
 274                         die "Arguments to unpack() cannot be absolute"
 275                 else
 276                         srcdir="${DISTDIR}/"
 277                 fi
 278                 [[ ! -s ${srcdir}${x} ]] && die "${x} does not exist"
 279 
 280                 myfail="failure unpacking ${x}"
 281                 case "${x##*.}" in
 282                         tar)
 283                                 tar xof "${srcdir}${x}" ${tar_opts} || die "$myfail"
 284                                 ;;
 285                         tgz)
 286                                 tar xozf "${srcdir}${x}" ${tar_opts} || die "$myfail"
 287                                 ;;
 288                         tbz|tbz2)
 289                                 bzip2 -dc "${srcdir}${x}" | tar xof - ${tar_opts}
 290                                 assert "$myfail"
 291                                 ;;
 292                         ZIP|zip|jar)
 293                                 unzip -qo "${srcdir}${x}" || die "$myfail"
 294                                 ;;
 295                         gz|Z|z)
 296                                 if [ "${y}" == "tar" ]; then
 297                                         tar zoxf "${srcdir}${x}" ${tar_opts} || die "$myfail"
 298                                 else
 299                                         gzip -dc "${srcdir}${x}" > ${x%.*} || die "$myfail"
 300                                 fi
 301                                 ;;
 302                         bz2|bz)
 303                                 if [ "${y}" == "tar" ]; then
 304                                         bzip2 -dc "${srcdir}${x}" | tar xof - ${tar_opts}
 305                                         assert "$myfail"
 306                                 else
 307                                         bzip2 -dc "${srcdir}${x}" > ${x%.*} || die "$myfail"
 308                                 fi
 309                                 ;;
 310                         7Z|7z)
 311                                 local my_output
 312                                 my_output="$(7z x -y "${srcdir}${x}")"
 313                                 if [ $? -ne 0 ]; then
 314                                         echo "${my_output}" >&2
 315                                         die "$myfail"
 316                                 fi
 317                                 ;;
 318                         RAR|rar)
 319                                 unrar x -idq -o+ "${srcdir}${x}" || die "$myfail"
 320                                 ;;
 321                         LHa|LHA|lha|lzh)
 322                                 lha xfq "${srcdir}${x}" || die "$myfail"
 323                                 ;;
 324                         a)
 325                                 ar x "${srcdir}${x}" || die "$myfail"
 326                                 ;;
 327                         deb)
 328                                 # Unpacking .deb archives can not always be done with
 329                                 # `ar`.  For instance on AIX this doesn't work out.  If
 330                                 # we have `deb2targz` installed, prefer it over `ar` for
 331                                 # that reason.  We just make sure on AIX `deb2targz` is
 332                                 # installed.
 333                                 if type -P deb2targz > /dev/null; then
 334                                         deb2targz "${srcdir}/${x}" || die "$myfail"
 335                                         mv "${srcdir}/${x/.deb/.tar.gz}" data.tar.gz
 336                                 else
 337                                         ar x "${srcdir}/${x}" || die "$myfail"
 338                                 fi
 339                                 ;;
 340                         lzma)
 341                                 if [ "${y}" == "tar" ]; then
 342                                         lzma -dc "${srcdir}${x}" | tar xof - ${tar_opts}
 343                                         assert "$myfail"
 344                                 else
 345                                         lzma -dc "${srcdir}${x}" > ${x%.*} || die "$myfail"
 346                                 fi
 347                                 ;;
 348                         *)
 349                                 vecho "unpack ${x}: file format not recognized. Ignoring."
 350                                 ;;
 351                 esac
 352         done
 353         # Do not chmod '.' since it's probably ${WORKDIR} and PORTAGE_WORKDIR_MODE
 354         # should be preserved.
 355         find . -mindepth 1 -maxdepth 1 ! -type l -print0 | \
 356                 ${XARGS} -0 chmod -fR a+rX,u+w,g-w,o-w
 357     }
 358     
 359     s(){
 360       if [ -r "${HOME}/.Xauthority" ]; then
 361         export XAUTHORITY=${HOME}/.Xauthority_${RANDOM}_${$}
 362         cp -pr ${HOME}/.Xauthority ${XAUTHORITY}
 363         chmod go+r ${XAUTHORITY}
 364       fi
 365       if [[ "${EUID}" == 0 ]]; then
 366         echo \"Executing su - $@\"
 367         su - $@       
 368       else
 369         if [ -f /opt/vw/local/scr/su_user ]; then
 370           if [ -z "${1}" ] || finger "${1}" 2>&1 | grep -q ": no such user." ; then
 371             SUDO_USER="$(/opt/LSF/bin/bjobs -w -u all -r -m ${HOSTNAME} 2>/dev/null | awk '/RUN/{print $2; exit}')"
 372             echo "No User provided guessing it: ${SUDO_USER}"
 373           fi
 374           sudo su_user ${SUDO_USER} $@
 375         fi
 376       fi
 377       rm -f ${XAUTHORITY}
 378       unset SUDO_USER XAUTHORITY
 379     }
 380 
 381     #VW commands
 382     # ------------------------------------------------
 383     for I in blsload bexec bpwd clocate bhwcheck bres; do
 384       eval alias $I=\'ssh scacc1 /opt/vw/bin/$I\'
 385     done
 386 
 387     case $(uname -n) in
 388         evebe919|wsntbk02*)
 389           for I in blsload bexec bpwd clocate bhwcheck bres; do
 390             eval alias $I=\'ssh scacc1 /opt/vw/bin/$I\'
 391           done
 392           if [ "${USER}" == etorabi ]; then
 393             alias ssh="f_keychain; ssh -AY"
 394             alias scp="f_keychain; scp -p"
 395             alias bsub="ssh scacc1 /opt/LSF/bin/bsub -P0OS3170"
 396           fi
 397           alias myjgen="~/jgen/bin/jgen"
 398           alias myxjgen="~/jgen/bin/xjgen"
 399           alias s="su - $@"
 400           f_keychain -Q --nolock --noask
 401         ;;
 402         sc*|scnec*|schp*|evebe700|evebe103)
 403           g(){
 404             if [ "$#" -eq "0" ]; then
 405               PIDS=$(ps -AlFwww | awk '{if ($2 == "R" && $3 !~ /root/ && $15 !~ /pts/) {print $0 > "/dev/stderr"; print $4}}')
 406             else
 407               PIDS="$@"
 408             fi
 409             for PID in ${PIDS}; do
 410               taskset -cp ${PID}
 411               gstack ${PID}
 412             done
 413           }
 414             
 415           # General function that uses variables from the .env file
 416           f_mv2ws(){
 417             mv2ws_error="(${USER}@${HOSTNAME}) ERROR in function f_mv2ws:"
 418             if [ $# -eq 0 ]; then
 419                 echo "$(f_date) ${mv2ws_error} a filename to copy needs to be provided" 1>&2
 420                 return 1
 421             fi
 422             MV2DIRARGS="-v"
 423             if [ "${1}" = "-k" ]; then
 424               MV2DIRARGS="${MV2DIRARGS} -k"
 425               shift
 426             fi
 427             if [ -z "${JOB_WSOUTDIR:-}" ]; then
 428               echo "$(f_date) ${mv2ws_error} The variable JOB_WSOUTDIR is empty." 1>&2
 429               return 2
 430             fi
 431             TARGET="${JOB_WSOUTDIR}"
 432             if [ $(echo "${JOB_WSOUTDIR:-}" | awk -F: '{print NF}') -eq 1 ]; then
 433               if [ -n "${JOB_WSNAME:-}" -a -n "${JOB_WSUSER:-}" ]; then
 434                 TARGET="${JOB_WSUSER}@${JOB_WSNAME}:${JOB_WSOUTDIR}"
 435               else
 436                 echo "$(f_date) ${mv2ws_error} could not set TARGET correctly" 1>&2
 437                 echo "$(f_date) ${mv2ws_error} JOB_WSUSER=\"${JOB_WSUSER}\" JOB_WSNAME=\"${JOB_WSNAME}\" JOB_WSOUTDIR=\"${JOB_WSOUTDIR}\"" 1>&2
 438                 return 3
 439               fi
 440             fi
 441             if [ "${JOB_WSUSESCP}" = 'yes' ]; then
 442                 MV2DIRARGS="${MV2DIRARGS} -s"
 443             fi
 444             for FILE in $@; do
 445               if [ -r "${FILE}" ]; then
 446                 [ "${JOB_WSGROUPW}" = 'yes' ] && chmod g+w ${FILE}
 447                 /opt/vw/bin/mv2dir ${MV2DIRARGS} ${TARGET} ${FILE}
 448               fi
 449             done
 450             unset mv2ws_error MV2DIRARGS TARGET FILE
 451           }
 452           
 453           # backward compatibility
 454           cp2ws(){ f_mv2ws -k $@;}
 455           
 456           f_run_on_ws(){
 457             if [ -z "${JOB_WSNAME}" -o -z "${JOB_WSOUTDIR}" -o -z ${JOB_WSUSER} ]; then
 458               echo "A required variable is empty" 1>&2
 459               echo -e "JOB_WSUSER=\"${JOB_WSUSER}\"\tJOB_WSNAME=\"${JOB_WSNAME}\"\tJOB_WSOUTDIR=\"${JOB_WSOUTDIR}\"" 1>&2
 460               return 1
 461             fi
 462             if [ $# -eq 0 ]; then
 463               echo "cd ${JOB_WSOUTDIR}"
 464               ssh ${JOB_WSUSER}@${JOB_WSNAME}
 465             else
 466              ssh ${JOB_WSUSER}@${JOB_WSNAME} "cd ${JOB_WSOUTDIR}; $@"
 467             fi
 468             return $?
 469           }
 470         
 471           # "R"un on all "H"osts of this "J"ob
 472           f_rhj(){
 473             if [ "$#" -eq "0" ]; then
 474               echo "You have to provide a command to execute" 1>&2
 475             fi
 476             if [ -z "${HOSTNAME}" -o -z "${JOB_HOSTLIST}" -o -z ${JOB_BATCHDIR} ]; then
 477               echo "A required varable is empty" 1>&2
 478               echo -e "HOSTNAME=\"${HOSTNAME}\"\JOB_HOSTLIST=\"${JOB_HOSTLIST}\"\JOB_BATCHDIR=\"${JOB_BATCHDIR}\"" 1>&2
 479             fi
 480             # only if the execution if $@ suceeds it will be performed on the other hosts as well
 481             if $@; then
 482               # Try to figure out if remote noninteractive execution will work
 483 #              if ALIAS=$(alias ${1}) 2>/dev/null; then
 484 #                ${1}="${ALIAS} "
 485 #              fi
 486 #              unset ALIAS
 487               for JOB_HOST in ${JOB_HOSTLIST}; do
 488                 if [ ${JOB_HOST} != ${HOSTNAME} ]; then
 489                   ssh -AY ${JOB_HOST} "cd ${JOB_BATCHDIR}; $@"
 490                 fi
 491               done
 492             else
 493               echo "The command \"$@\" failed to execute locally. No remote execution will be performed" 1>&2
 494             fi
 495           }
 496         
 497           for I in blsload bexec bpwd clocate bhwcheck bres; do
 498             eval unalias ${I}
 499           done
 500           if [ "${USER}" = "etorabi" ]; then
 501             alias bsub="bsub -P0OS3170"
 502           fi
 503           if which bjoblog 2>/dev/null 1>&2; then
 504             alias bjob="bjobs" 
 505           fi
 506           JOB_BATCHDIR=$(ls -ld /tmp/BATCH.${USER}.${LSB_JOBID:=*} 2>/dev/null | awk '/\/tmp\/BATCH.'${USER}'/{print $NF; exit}')
 507           if [ "${JOB_BATCHDIR}" ]; then
 508             if [ -r "${JOB_BATCHDIR}/.env" ]; then
 509               # We are on the first node
 510               source ${JOB_BATCHDIR}/.env
 511             else
 512               LSB_JOBID=${LSB_JOBID:=$(ls -ld /tmp/BATCH.${USER}.* 2>/dev/null | awk -F'/' '{print $(NF-1)}' | awk -F'.' '{print $NF; exit}')}         #'
 513               FIRSTHOST=$(/opt/LSF/bin/bjobs ${LSB_JOBID} | awk '/RUN/ {print $6}' | awk -F'*' '{print $2}')
 514               JOB_ENV="/hosts/${FIRSTHOST}/$(echo ${JOB_BATCHDIR} | awk -F'/' '{print $3}')/.env"
 515               source ${JOB_ENV} || echo "Could not source JOB_ENV=\"${JOB_ENV}\" . "
 516             fi
 517             cd ${JOB_BATCHDIR}
 518             if [ "${JOB_APPL_FUNCTIONS}" ]; then
 519               # RT: source ${JOB_APPL_FUNCTIONS} for interactive usage
 520               source ${JOB_APPL_FUNCTIONS}
 521             fi
 522           fi
 523         ;;
 524         e?ebe*)
 525           for CMD in bacct bhosts bjobs bhist lshosts bstop bresume brequeue bswitch brun bkill bqueues bmod btop bbot bpeek bjdepinfo lsload ; do
 526             if [ -x /opt/LSF/bin/${CMD} ]; then
 527               eval alias ${CMD}=/opt/LSF/bin/${CMD}
 528             else
 529               eval alias ${CMD}=\'ssh scacc1 /opt/LSF/bin/${CMD}\'
 530             fi
 531           done
 532           if [ -x /opt/LSF/bin/bsub ]; then
 533             alias bsub="/opt/LSF/bin/bsub -P0OS3170"
 534           else
 535             alias bsub="ssh scacc1 /opt/LSF/bin/bsub -P0OS3170"
 536           fi
 537         ;;
 538         *)
 539         ;;
 540     esac
 541     
 542     # recreate the contents of this file by starting as root@cae-support
 543     #   ssh hpcappl@scacc1 "env ENV=/opt/vw/etc/kshrc KSHRC_IFLAG=1 /bin/ksh -c set" | grep ^SC > /appl/tools/beta/vwhpc.hosts
 544     for HOSTLIST in /shared/appl/tools/beta/vwhpc.hosts /appl/tools/beta/vwhpc.hosts ~/.vwhpc.hosts; do
 545       if [ -r "${HOSTLIST}" ]; then
 546         source ${HOSTLIST} && break
 547       fi
 548     done
 549     
 550     SCC="${SC_ML370} $SCC7 $SCC8 $SCC9 ${SC10} ${SCC1} ${SCC2} ${SCC3} ${SCC5} ${SCC4} ${SCC6} ${SCNVH} ${SC_EVEBE}"
 551     
 552     for I in ${SCC} scacc1; do
 553       eval alias ${I}=\'ssh ${I}\'
 554     done
 555 
 556 #  if [[ ${EUID} == 0 ]] ; then
 557 #    export PS1='\[\033[1;33m\]\t \[\033[1m\]\[\033[1;31m\]\h:\[\033[1;34m\]\w \$\[\033[00m\] '
 558 #  else
 559 
 560    # create coloured bash prompt
 561    # black background
 562    PS1="\[\033[1;40m\]"
 563    # yellow time
 564    PS1="${PS1}\[\033[1;33m\]\d \t"
 565    case ${USER} in
 566      fox0fdn)
 567        # green
 568        PS1="${PS1} \[\033[1;32m\]\u"
 569      ;;
 570      root)
 571        # red
 572        PS1="${PS1} \[\033[1;31m\]\u"
 573      ;;
 574      *)
 575        # light blue
 576        PS1="${PS1} \[\033[1;36m\]\u"
 577      ;;
 578    esac
 579    # gray
 580    PS1="${PS1}\[\033[1;30m\]@"
 581     case ${HOSTNAME} in
 582       wsntbk02*)
 583         # reset to black background and green hostname (no username)
 584         PS1="\[\033[1;40m\]\[\033[1;33m\]\t "
 585         if [[ "${EUID}" == 0 ]]; then
 586           # red
 587           PS1="${PS1}\[\033[1;31m\]\h"
 588         else
 589           # green
 590           PS1="${PS1}\[\033[1;32m\]\h"
 591         fi
 592       ;;
 593       evebe919)
 594         # green
 595         PS1="${PS1}\[\033[1;32m\]\h"
 596 #        export PATH=~/jgen/bin/:$PATH
 597       ;;
 598       evebe777|evebe759)
 599         # red
 600         PS1="${PS1}\[\033[1;31m\]\h"
 601       ;;      
 602       e?ebe*)
 603         # white
 604         PS1="${PS1}\[\033[1;37m\]\h"
 605       ;;
 606       e?evm*)
 607         # white
 608         PS1="${PS1}\[\033[1;35m\]\h"
 609       ;;
 610       schp0*|scacc1)
 611         # light blue
 612         PS1="${PS1}\[\033[1;36m\]\h"
 613         unset brun bjobs
 614       ;;
 615       scc*|schp*)
 616         # light blue
 617         PS1="${PS1}\[\033[1;36m\]\h"
 618       ;;
 619       *)
 620         # pink
 621         PS1="${PS1}\[\033[1;35m\]\h"
 622       ;;
 623     esac
 624     export PS1="${PS1}\[\033[1;30m\]:\[\033[1;34m\]\w \$\[\033[00m\] "
 625 #  fi
 626   ;;
 627   *)
 628   : # This shell is not interactive
 629   ;;
 630 esac
 631 
 632 #if [ "${USER}" = "etorabi" -a "${HOSTNAME}" = "evebe700" ]; then
 633 #  unalias s 2>/dev/null
 634 #  s(){
 635 #    echo "executing \"sudo su - $@ /opt/vw/shared/appl/tools/beta/etorabi\"" 1>&2
 636 #    sudo su - $@ /opt/vw/shared/appl/tools/beta/etorabi
 637 #  }
 638 #fi
 639 bjur(){
 640   delay='60'
 641   [ $# -gt 1 ] && delay="$2"
 642   while :; do
 643     clear
 644     echo "Updated at "`date +%H:%M:%S`
 645     bjobs -u $1
 646     sleep $delay
 647   done
 648 }
 649 
 650 bjud() {
 651   delay='60'
 652   [ $# -gt 1 ] && delay="$2"
 653   while :; do
 654     clear
 655     echo "Updated at "`date +%H:%M:%S`
 656     bjobs -u $1 -d | tail -n 50
 657     sleep $delay
 658   done
 659 }
 660 
 661 bju() {
 662   delay='60'
 663   [ $# -gt 1 ] && delay="$2"
 664   while :; do
 665     clear
 666     echo "Updated at "`date +%H:%M:%S`
 667     bjobs -u $1
 668     echo ".-'-.-'-.-'-.-'-.-'-.-'-.-'-.-'-.-'-.-'-.-'-.-'-.-'-.-'-.-'-.-'-.-'-.-'-.-'-.-'-"
 669     bjobs -u $1 -d | tail -n 50
 670     sleep $delay
 671   done
 672 }
 673 
 674 bjq() {
 675   delay='60'
 676   [ $# -gt 1 ] && delay="$2"
 677   while :; do
 678     clear
 679     echo "Updated at "`date +%H:%M:%S`
 680     bjobs -q $1 -u all
 681     echo
 682     bjobs -q $1 -u all -d | tail -n 50
 683     sleep $delay
 684   done
 685 }
 686 
 687 # support colors in less
 688 export LESS_TERMCAP_mb=$'\E[01;31m'
 689 export LESS_TERMCAP_md=$'\E[01;31m'
 690 export LESS_TERMCAP_me=$'\E[0m'
 691 export LESS_TERMCAP_se=$'\E[0m'
 692 export LESS_TERMCAP_so=$'\E[01;44;33m'
 693 export LESS_TERMCAP_ue=$'\E[0m'
 694 export LESS_TERMCAP_us=$'\E[01;32m'

Wikinger: ComputerKram/Bash (zuletzt geändert am 2014-12-01 15:24:51 durch Robert)