You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
3.2 KiB

  1. [[ $- != *i* ]] && return
  2. colors() {
  3. local fgc bgc vals seq0
  4. printf "Color escapes are %s\n" '\e[${value};...;${value}m'
  5. printf "Values 30..37 are \e[33mforeground colors\e[m\n"
  6. printf "Values 40..47 are \e[43mbackground colors\e[m\n"
  7. printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n"
  8. # foreground colors
  9. for fgc in {30..37}; do
  10. # background colors
  11. for bgc in {40..47}; do
  12. fgc=${fgc#37} # white
  13. bgc=${bgc#40} # black
  14. vals="${fgc:+$fgc;}${bgc}"
  15. vals=${vals%%;}
  16. seq0="${vals:+\e[${vals}m}"
  17. printf " %-9s" "${seq0:-(default)}"
  18. printf " ${seq0}TEXT\e[m"
  19. printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m"
  20. done
  21. echo; echo
  22. done
  23. }
  24. [ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
  25. # Change the window title of X terminals
  26. case ${TERM} in
  27. xterm*|rxvt*|Eterm*|aterm|kterm|gnome*|interix|konsole*)
  28. PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\007"'
  29. ;;
  30. screen*)
  31. PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\033\\"'
  32. ;;
  33. esac
  34. use_color=true
  35. # Set colorful PS1 only on colorful terminals.
  36. # dircolors --print-database uses its own built-in database
  37. # instead of using /etc/DIR_COLORS. Try to use the external file
  38. # first to take advantage of user additions. Use internal bash
  39. # globbing instead of external grep binary.
  40. safe_term=${TERM//[^[:alnum:]]/?} # sanitize TERM
  41. match_lhs=""
  42. [[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
  43. [[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
  44. [[ -z ${match_lhs} ]] \
  45. && type -P dircolors >/dev/null \
  46. && match_lhs=$(dircolors --print-database)
  47. [[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true
  48. if ${use_color} ; then
  49. # Enable colors for ls, etc. Prefer ~/.dir_colors #64489
  50. if type -P dircolors >/dev/null ; then
  51. if [[ -f ~/.dir_colors ]] ; then
  52. eval $(dircolors -b ~/.dir_colors)
  53. elif [[ -f /etc/DIR_COLORS ]] ; then
  54. eval $(dircolors -b /etc/DIR_COLORS)
  55. fi
  56. fi
  57. if [[ ${EUID} == 0 ]] ; then
  58. PS1='\[\033[01;31m\][\h\[\033[01;36m\] \W\[\033[01;31m\]]\$\[\033[00m\] '
  59. else
  60. PS1='\[\033[01;32m\][\u@\h\[\033[01;37m\] \W\[\033[01;32m\]]\$\[\033[00m\] '
  61. fi
  62. alias ls='ls --color=auto'
  63. alias grep='grep --colour=auto'
  64. alias egrep='egrep --colour=auto'
  65. alias fgrep='fgrep --colour=auto'
  66. else
  67. if [[ ${EUID} == 0 ]] ; then
  68. # show root@ when we don't have colors
  69. PS1='\u@\h \W \$ '
  70. else
  71. PS1='\u@\h \w \$ '
  72. fi
  73. fi
  74. unset use_color safe_term match_lhs sh
  75. if [[ -f "$HOME/.bash_aliases" ]]; then
  76. source $HOME/.bash_aliases
  77. fi
  78. export EDITOR=vim