Facebook
From lingruby, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 246
  1. # /etc/bash/bashrc
  2. #
  3. # This file is sourced by all *interactive* bash shells on startup,
  4. # including some apparently interactive shells such as scp and rcp
  5. # that can't tolerate any output.  So make sure this doesn't display
  6. # anything or bad things will happen !
  7.  
  8.  
  9. # Test for an interactive shell.  There is no need to set anything
  10. # past this point for scp and rcp, and it's important to refrain from
  11. # outputting anything in those cases.
  12. if [[ $- != *i* ]] ; then
  13.         # Shell is non-interactive.  Be done now!
  14.         return
  15. fi
  16.  
  17. # Bash won't get SIGWINCH if another process is in the foreground.
  18. # Enable checkwinsize so that bash will check the terminal size when
  19. # it regains control.  #65623
  20. # https://tiswww.case.edu/php/chet/bash/FAQ (E11)
  21. shopt -s checkwinsize
  22.  
  23. # Disable completion when the input buffer is empty.  i.e. Hitting tab
  24. # and waiting a long time for bash to expand all of $PATH.
  25. shopt -s no_empty_cmd_completion
  26.  
  27. # Enable history appending instead of overwriting when exiting.  #139609
  28. shopt -s histappend
  29.  
  30. # Save each command to the history file as it's executed.  #517342
  31. # This does mean sessions get interleaved when reading later on, but this
  32. # way the history is always up to date.  History is not synced across live
  33. # sessions though; that is what `history -n` does.
  34. # Disabled by default due to concerns related to system recovery when $HOME
  35. # is under duress, or lives somewhere flaky (like NFS).  Constantly syncing
  36. # the history will halt the shell prompt until it's finished.
  37. #PROMPT_COMMAND='history -a'
  38.  
  39. # Change the window title of X terminals
  40. case ${TERM} in
  41.         [aEkx]term*|rxvt*|gnome*|konsole*|interix)
  42.                 PS1='\[\033]0;\u@\h:\w\007\]'
  43.                 ;;
  44.         screen*)
  45.                 PS1='\[\033k\u@\h:\w\033\\\]'
  46.                 ;;
  47.         *)
  48.                 unset PS1
  49.                 ;;
  50. esac
  51.  
  52. # Set colorful PS1 only on colorful terminals.
  53. # dircolors --print-database uses its own built-in database
  54. # instead of using /etc/DIR_COLORS.  Try to use the external file
  55. # first to take advantage of user additions.
  56. use_color=false
  57. if type -P dircolors >/dev/null ; then
  58.         # Enable colors for ls, etc.  Prefer ~/.dir_colors #64489
  59.         LS_COLORS=
  60.         if [[ -f ~/.dir_colors ]] ; then
  61.                 # If you have a custom file, chances are high that it's not the default.
  62.                 used_default_dircolors="no"
  63.                 eval "$(dircolors -b ~/.dir_colors)"
  64.         elif [[ -f /etc/DIR_COLORS ]] ; then
  65.                 # People might have customized the system database.
  66.                 used_default_dircolors="maybe"
  67.                 eval "$(dircolors -b /etc/DIR_COLORS)"
  68.         else
  69.                 used_default_dircolors="yes"
  70.                 eval "$(dircolors -b)"
  71.         fi
  72.         if [[ -n ${LS_COLORS:+set} ]] ; then
  73.                 use_color=true
  74.         fi
  75.         unset used_default_dircolors
  76. else
  77.         # Some systems (e.g. BSD & embedded) don't typically come with
  78.         # dircolors so we need to hardcode some terminals in here.
  79.         case ${TERM} in
  80.         [aEkx]term*|rxvt*|gnome*|konsole*|screen|cons25|*color) use_color=true;;
  81.         esac
  82. fi
  83.  
  84. if ${use_color} ; then
  85.         if [[ ${EUID} == 0 ]] ; then
  86.                 PS1+='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
  87.         else
  88.                 PS1+='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
  89.         fi
  90.  
  91.         alias ls='ls --color=auto'
  92.         alias grep='grep --colour=auto'
  93.         alias egrep='egrep --colour=auto'
  94.         alias fgrep='fgrep --colour=auto'
  95. else
  96.         if [[ ${EUID} == 0 ]] ; then
  97.                 # show root@ when we don't have colors
  98.                 PS1+='\u@\h \W \$ '
  99.         else
  100.                 PS1+='\u@\h \w \$ '
  101.         fi
  102. fi
  103.  
  104. for sh in /etc/bash/bashrc.d/* ; do
  105.         [[ -r ${sh} ]] && source "${sh}"
  106. done
  107.  
  108. # Try to keep environment pollution down, EPA loves us.
  109. unset use_color sh