Advertisement
ariyasa

bash.bashrc

Jan 23rd, 2014
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 KB | None | 0 0
  1. # /etc/bash.bashrc
  2. #
  3. # https://wiki.archlinux.org/index.php/Color_Bash_Prompt
  4. #
  5. # This file is sourced by all *interactive* bash shells on startup,
  6. # including some apparently interactive shells such as scp and rcp
  7. # that can't tolerate any output. So make sure this doesn't display
  8. # anything or bad things will happen !
  9.  
  10. # Test for an interactive shell. There is no need to set anything
  11. # past this point for scp and rcp, and it's important to refrain from
  12. # outputting anything in those cases.
  13.  
  14. # If not running interactively, don't do anything!
  15. [[ $- != *i* ]] && return
  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.
  20. # http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
  21. shopt -s checkwinsize
  22.  
  23. # Enable history appending instead of overwriting.
  24. shopt -s histappend
  25.  
  26. case ${TERM} in
  27. xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
  28. PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
  29. ;;
  30. screen)
  31. PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
  32. ;;
  33. esac
  34.  
  35. # fortune is a simple program that displays a pseudorandom message
  36. # from a database of quotations at logon and/or logout.
  37. # If you wish to use it, please install "fortune-mod" from the
  38. # official repositories, then uncomment the following line:
  39.  
  40. # [[ "$PS1" ]] && /usr/bin/fortune
  41.  
  42. # Set colorful PS1 only on colorful terminals.
  43. # dircolors --print-database uses its own built-in database
  44. # instead of using /etc/DIR_COLORS. Try to use the external file
  45. # first to take advantage of user additions. Use internal bash
  46. # globbing instead of external grep binary.
  47.  
  48. # sanitize TERM:
  49. safe_term=${TERM//[^[:alnum:]]/?}
  50. match_lhs=""
  51.  
  52. [[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
  53. [[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
  54. [[ -z ${match_lhs} ]] \
  55. && type -P dircolors >/dev/null \
  56. && match_lhs=$(dircolors --print-database)
  57.  
  58. if [[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] ; then
  59.  
  60. # we have colors :-)
  61.  
  62. # Enable colors for ls, etc. Prefer ~/.dir_colors
  63. if type -P dircolors >/dev/null ; then
  64. if [[ -f ~/.dir_colors ]] ; then
  65. eval $(dircolors -b ~/.dir_colors)
  66. elif [[ -f /etc/DIR_COLORS ]] ; then
  67. eval $(dircolors -b /etc/DIR_COLORS)
  68. fi
  69. fi
  70.  
  71. PS1="\[\033[0;37m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] && echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[0;31m\]\h'; else echo '\[\033[0;33m\]\u\[\033[0;37m\]@\[\033[0;96m\]\h'; fi)\[\033[0;37m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;37m\]]\n\[\033[0;37m\]\342\224\224\342\224\200\342\224\200\342\225\274 \[\033[0m\]"
  72.  
  73. # Use this other PS1 string if you want \W for root and \w for all other users:
  74. # PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h\[\033[01;34m\] \W'; else echo '\[\033[01;32m\]\u@\h\[\033[01;34m\] \w'; fi) \$([[ \$? != 0 ]] && echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\\$\[\033[00m\] "
  75.  
  76. alias ls="ls --color=auto"
  77. alias dir="dir --color=auto"
  78. alias grep="grep --color=auto"
  79. alias dmesg='dmesg --color'
  80.  
  81. # Uncomment the "Color" line in /etc/pacman.conf instead of uncommenting the following line...!
  82.  
  83. # alias pacman="pacman --color=auto"
  84.  
  85. else
  86.  
  87. # show root@ when we do not have colors
  88.  
  89. PS1="\[\033[0;37m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] && echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[0;31m\]\h'; else echo '\[\033[0;33m\]\u\[\033[0;37m\]@\[\033[0;96m\]\h'; fi)\[\033[0;37m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;37m\]]\n\[\033[0;37m\]\342\224\224\342\224\200\342\224\200\342\225\274 \[\033[0m\]"
  90.  
  91. # Use this other PS1 string if you want \W for root and \w for all other users:
  92. # PS1="\u@\h $(if [[ ${EUID} == 0 ]]; then echo '\W'; else echo '\w'; fi) \$([[ \$? != 0 ]] && echo \":( \")\$ "
  93.  
  94. fi
  95.  
  96. PS2="> "
  97. PS3="> "
  98. PS4="+ "
  99.  
  100. # Try to keep environment pollution down, EPA loves us.
  101. unset safe_term match_lhs
  102.  
  103. # Try to enable the auto-completion (type: "pacman -S bash-completion" to install it).
  104. [ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
  105.  
  106. # Try to enable the "Command not found" hook ("pacman -S pkgfile" to install it).
  107. # See also: https://wiki.archlinux.org/index.php/Bash#The_.22command_not_found.22_hook
  108. [ -r /usr/share/doc/pkgfile/command-not-found.bash ] && . /usr/share/doc/pkgfile/command-not-found.bash
  109. screenfetch
  110. date
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement