home *** CD-ROM | disk | FTP | other *** search
/ chilidog.highland.cc.ks.us / chilidog.highland.cc.ks.us.zip / chilidog.highland.cc.ks.us / backup / bradford.20120521.etc.tar.gz / bradford.20120521.etc.tar / etc / bash.bashrc < prev    next >
Text File  |  2006-04-27  |  7KB  |  292 lines

  1. # /etc/bash.bashrc for SuSE Linux
  2. #
  3. # PLEASE DO NOT CHANGE /etc/bash.bashrc There are chances that your changes
  4. # will be lost during system upgrades.  Instead use /etc/bash.bashrc.local
  5. # for your local settings, favourite global aliases, VISUAL and EDITOR
  6. # variables, etc ...
  7.  
  8. #
  9. # Check which shell is reading this file
  10. #
  11. if test -z "$is" ; then
  12.  if test -f /proc/mounts ; then
  13.   case "`/bin/ls -l /proc/$$/exe`" in
  14.     */bash)    is=bash ;;
  15.     */rbash)    is=bash ;;
  16.     */ash)    is=ash  ;;
  17.     */ksh)    is=ksh  ;;
  18.     */pdksh)    is=ksh  ;;
  19.     */zsh)    is=zsh  ;;
  20.     */*)    is=sh   ;;
  21.   esac
  22.  else
  23.   is=sh
  24.  fi
  25. fi
  26.  
  27. #
  28. # ksh/ash soemtimes do not know
  29. #
  30. test -z "$UID"  && readonly  UID=`id -ur 2> /dev/null`
  31. test -z "$EUID" && readonly EUID=`id -u  2> /dev/null`
  32.  
  33. #
  34. # Colored file listings
  35. #
  36. if test -x /usr/bin/dircolors ; then
  37.     #
  38.     # set up the color-ls environment variables:
  39.     #
  40.     if test -f $HOME/.dir_colors ; then
  41.     eval "`dircolors -b $HOME/.dir_colors`"
  42.     elif test -f /etc/DIR_COLORS ; then
  43.     eval "`dircolors -b /etc/DIR_COLORS`"
  44.     fi
  45. fi
  46.  
  47. #
  48. # ls color option depends on the terminal
  49. # If LS_COLROS is set but empty, the terminal has no colors.
  50. #
  51. if test "${LS_COLORS+empty}" = "${LS_COLORS:+empty}" ; then
  52.     LS_OPTIONS=--color=tty
  53. else
  54.     LS_OPTIONS=--color=none
  55. fi
  56. if test "$UID" = 0 ; then
  57.     LS_OPTIONS="-A -N $LS_OPTIONS -T 0"
  58. else
  59.     LS_OPTIONS="-N $LS_OPTIONS -T 0"
  60. fi
  61.  
  62. #
  63. # Avoid trouble with Emacs shell mode
  64. #
  65. if test "$EMACS" = "t" ; then
  66.     LS_OPTIONS='-N --color=none -T 0';
  67.     tset -I -Q
  68.     stty cooked pass8 dec nl -echo
  69. fi
  70. export LS_OPTIONS
  71.  
  72. #
  73. # Set prompt and aliases to something useful for an interactive shell
  74. #
  75. case "$-" in
  76. *i*)
  77.     #
  78.     # Some useful functions
  79.     #
  80.     startx  () {
  81.     test -x /usr/X11R6/bin/startx || {
  82.         echo "No startx installed" 1>&2
  83.         return 1;
  84.     }
  85.     /usr/X11R6/bin/startx ${1+"$@"} 2>&1 | tee $HOME/.X.err
  86.     }
  87.  
  88.     remount () { /bin/mount -o remount,${1+"$@"} ; }
  89.  
  90.     #
  91.     # Set prompt to something useful
  92.     #
  93.     case "$is" in
  94.     bash)
  95.     # Force a reset of the readline library
  96.     unset TERMCAP
  97.     # Returns short path (last two directories)
  98.     spwd () {
  99.       ( IFS=/
  100.         set $PWD
  101.         if test $# -le 3 ; then
  102.         echo "$PWD"
  103.         else
  104.         eval echo \"..\${$(($#-1))}/\${$#}\"
  105.         fi ) ; }
  106.     # Set xterm prompt with short path (last 18 characters)
  107.     ppwd () {
  108.         local _t="$1" _w _x _u="$USER" _h="$HOST"
  109.         test -n "$_t"    || return
  110.         test "${_t#tty}" = $_t && _t=pts/$_t
  111.         test -O /dev/$_t || return
  112.         _w="$(dirs +0)"
  113.         _x=$((${#_w}-18))
  114.         test ${#_w} -le 18 || _w="...${_w#$(printf "%.*s" $_x "$_w")}"
  115.         printf "\e]2;%s@%s:%s\007\e]1;%s\007" "$_u" "$_h" "$_w" "$_h" > /dev/$_t
  116.         }
  117.     # If set: do not follow sym links
  118.     # set -P
  119.     #
  120.     # Other prompting for root
  121.     _t=""
  122.     if test "$UID" = 0 ; then
  123.         _u="\h"
  124.         _p=" #"
  125.     else
  126.         _u="\u@\h"
  127.         _p=">"
  128.         if test \( "$TERM" = "xterm" -o "${TERM#screen}" != "$TERM" \) \
  129.             -a -z "$EMACS" -a -z "$MC_SID" -a -n "$DISPLAY"
  130.         then
  131.         _t="\$(ppwd \l)"
  132.         fi
  133.     fi
  134.     # With full path on prompt
  135.     PS1="${_t}${_u}:\w${_p} "
  136. #    # With short path on prompt
  137. #    PS1="${_t}${_u}:\$(spwd)${_p} "
  138. #    # With physical path even if reached over sym link
  139. #    PS1="${_t}${_u}:\$(pwd -P)${_p} "
  140.     unset _u _p _t
  141.     ;;
  142.     ash)
  143.     cd () {
  144.         local ret
  145.         command cd "$@"
  146.         ret=$?
  147.         PWD=$(pwd)
  148.         if test "$UID" = 0 ; then
  149.         PS1="${HOST}:${PWD} # "
  150.         else
  151.         PS1="${USER}@${HOST}:${PWD}> "
  152.         fi
  153.         return $ret
  154.     }
  155.     cd .
  156.     ;;
  157.     ksh)
  158.     if test "$UID" = 0 ; then
  159.         PS1="${HOST}:"'${PWD}'" # "
  160.     else
  161.         PS1="${USER}@${HOST}:"'${PWD}'"> "
  162.     fi
  163.     ;;
  164.     zsh)
  165. #    setopt chaselinks
  166.     if test "$UID" = 0; then
  167.         PS1='%n@%m:%~ # '
  168.     else
  169.         PS1='%n@%m:%~> '
  170.     fi
  171.     ;;
  172.     *)
  173. #    PS1='\u:\w\$ '
  174.     PS1='\h:\w\$ '
  175.     ;;
  176.     esac
  177.     PS2='> '
  178.  
  179.     if test "$is" = "ash" ; then
  180.     # The ash shell does not have an alias builtin in
  181.     # therefore we use functions here. This is a seperate
  182.     # file because other shells may run into trouble
  183.     # if they parse this even if they do not expand.
  184.     test -s /etc/profile.d/alias.ash && . /etc/profile.d/alias.ash
  185.     else
  186.     unalias ls 2>/dev/null
  187.     if test "$is" = "zsh" ; then
  188.         alias ls='/bin/ls $=LS_OPTIONS'
  189.     else
  190.         alias ls='/bin/ls $LS_OPTIONS'
  191.     fi
  192.     alias dir='ls -l'
  193.     alias ll='ls -l'
  194.     alias la='ls -la'
  195.     alias l='ls -alF'
  196.     alias ls-l='ls -l'
  197.  
  198.     #
  199.     # Set some generic aliases
  200.     #
  201.     alias o='less'
  202.     alias ..='cd ..'
  203.     alias ...='cd ../..'
  204.     alias cd..='cd ..'
  205.     if test "$is" != "ksh" ; then
  206.         alias -- +='pushd .'
  207.         alias -- -='popd'
  208.     fi
  209.     alias rd=rmdir
  210.     alias md='mkdir -p'
  211.     if test "$is" = "bash" ; then
  212.         #
  213.         # Other shells use the which command in path (e.g. ash) or
  214.         # their own builtin for the which command (e.g. ksh and zsh).
  215.         #
  216.         _which () {
  217.         local file=$(type -p ${1+"$@"} 2>/dev/null)
  218.         if test -n "$file" -a -x "$file"; then
  219.             echo "$file"
  220.             return 0
  221.         fi
  222.         hash -r
  223.         type -P ${1+"$@"}
  224.         }
  225.         alias which=_which
  226.     fi
  227.     alias rehash='hash -r'
  228.     alias you='su - -c "/sbin/yast2 online_update"'
  229.     if test "$is" != "ksh" ; then
  230.         alias beep='echo -en "\007"' 
  231.     else
  232.         alias beep='echo -en "\x07"'
  233.     fi
  234.     alias unmount='echo "Error: Try the command: umount" 1>&2; false'
  235.     test -s $HOME/.alias && . $HOME/.alias
  236.     fi
  237.  
  238.     #
  239.     # Expert mode: if we find $HOME/.bash.expert we skip our settings
  240.     # used for interactive completion and read in the expert file.
  241.     #
  242.     if test "$is" = "bash" -a -r $HOME/.bash.expert ; then
  243.     . $HOME/.bash.expert
  244.     elif test "$is" = "bash" ; then
  245.     # Complete builtin of the bash 2.0 and higher
  246.     case "$BASH_VERSION" in
  247.     [2-9].*)
  248.         if test -e $HOME/.bash_completion ; then
  249.         . $HOME/.bash_completion
  250.         elif test -e /etc/bash_completion ; then
  251.         . /etc/bash_completion
  252.         elif test -s /etc/profile.d/complete.bash ; then
  253.         . /etc/profile.d/complete.bash
  254.         fi
  255.         for s in /etc/bash_completion.d/*.sh ; do
  256.         test -r $s && . $s
  257.         done
  258.         ;;
  259.     *)  ;;
  260.     esac
  261.     fi
  262.  
  263.     # Do not save dupes and lines starting by space in the bash history file
  264.     HISTCONTROL=ignoreboth
  265.     if test "$is" = "ksh" ; then
  266.     # Use a ksh specific history file and enable
  267.         # emacs line editor
  268.         : ${HISTFILE=$HOME/.kshrc_history}
  269.         : ${VISUAL=emacs}
  270.     fi
  271.     ;;
  272. esac
  273.  
  274. #
  275. # Just in case the user excutes a command with ssh
  276. #
  277. if test -n "$SSH_CLIENT" -a -z "$PROFILEREAD" ; then
  278.     . /etc/profile > /dev/null 2>&1
  279. fi
  280.  
  281. if test "$is" != "ash" ; then
  282.     #
  283.     # And now let's see if there is a local bash.bashrc
  284.     # (for options defined by your sysadmin, not SuSE Linux)
  285.     #
  286.     test -s /etc/bash.bashrc.local && . /etc/bash.bashrc.local
  287. fi
  288.  
  289. #
  290. # End of /etc/bash.bashrc
  291. #
  292.