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.

155 lines
3.8 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. # ~/.bashrc: executed by bash(1) for non-login shells.
  2. # If not running interactively, don't do anything
  3. case $- in
  4. *i*) ;;
  5. *) return;;
  6. esac
  7. # don't put duplicate lines or lines starting with space in the history.
  8. HISTCONTROL=ignoreboth
  9. # append to the history file, don't overwrite it
  10. shopt -s histappend
  11. # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
  12. HISTSIZE=1000
  13. HISTFILESIZE=2000
  14. # check the window size after each command and, if necessary,
  15. # update the values of LINES and COLUMNS.
  16. shopt -s checkwinsize
  17. # make less more friendly for non-text input files, see lesspipe(1)
  18. [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
  19. # set a fancy prompt (non-color, unless we know we "want" color)
  20. case "$TERM" in
  21. xterm-color|*-256color)
  22. color_prompt=yes
  23. export COLOR_OPTIONS='--color=auto'
  24. ;;
  25. esac
  26. # enable programmable completion features (you don't need to enable
  27. # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
  28. # sources /etc/bash.bashrc).
  29. if ! shopt -oq posix; then
  30. if [ -f /usr/share/bash-completion/bash_completion ]; then
  31. . /usr/share/bash-completion/bash_completion
  32. elif [ -f /etc/bash_completion ]; then
  33. . /etc/bash_completion
  34. fi
  35. fi
  36. __prompt_command() {
  37. local EXIT="$?" # This needs to be first
  38. local R='\[\e[0m\]'
  39. local Red='\[\e[1;31m\]'
  40. local Gre='\[\e[1;32m\]'
  41. local Yel='\[\e[1;33m\]'
  42. local Ora='\[\e[0;33m\]'
  43. local Blu='\[\e[1;34m\]'
  44. local Cya='\[\e[1;36m\]'
  45. local Mag='\[\e[1;95m\]'
  46. local Gra='\[\e[1;30m\]'
  47. PS1=''
  48. if [[ $container == 'lxc' ]];then
  49. PS1+="${Gra}[LXC:${R}"
  50. local host=$container_hostname
  51. case ${host:0:4} in
  52. 'beta')
  53. PS1+="${Ora}";;
  54. 'prod')
  55. PS1+="${Red}";;
  56. *)
  57. esac
  58. PS1+="${host}${Gra}] "
  59. fi
  60. if [ `id -u` -eq 0 ]; then
  61. PS1+="${Yel}\u${R}"
  62. PROMPT='$'
  63. else
  64. PS1+="$Gre\u$R"
  65. PROMPT='#'
  66. fi
  67. PS1+="${Gra}@"
  68. case ${HOSTNAME:0:4} in
  69. 'beta')
  70. PS1+="${Ora}";;
  71. 'prod')
  72. PS1+="${Red}";;
  73. *)
  74. PS1+="${R}";;
  75. esac
  76. PS1+="\h"
  77. PS1+=" ${Cya}\w${R}"
  78. if [ $EXIT != 0 ]; then
  79. PS1+="$Mag" # Add red if exit code non 0
  80. else
  81. PS1+="$Gra"
  82. fi
  83. if hash git 2>&-; then
  84. # git command exists
  85. if git rev-parse --git-dir > /dev/null 2>&1; then
  86. # current dir is version controlled
  87. local branch=$(git branch 2> /dev/null | grep -e ^* | cut -d ' ' -f2)
  88. PS1+=" ${R}[${Mag}${branch}${R}|"
  89. local dirty=$(git status -s | wc -l)
  90. if [[ $dirty -ne 0 ]]; then
  91. PS1+="${Mag}…$dirty"
  92. else
  93. local ahead=$(git rev-list --branches --not --remotes |wc -l)
  94. if [[ $ahead -ne 0 ]]; then
  95. PS1+="${Blu}↑${ahead}"
  96. else
  97. PS1+="${Gre}✔"
  98. fi
  99. fi
  100. PS1+="${R}]"
  101. fi
  102. fi
  103. PS1+=" $PROMPT ${R}"
  104. }
  105. PROMPT_COMMAND='__prompt_command' # Func to gen PS1 after CMDs
  106. DEBIAN_BASH_DIR=/opt/debian-bash
  107. # You may uncomment the following lines if you want `ls' to be colorized:
  108. alias ls='ls $COLOR_OPTIONS'
  109. alias ll='ls $COLOR_OPTIONS -l'
  110. alias l=ls
  111. alias la='ls $COLOR_OPTIONS -lA'
  112. alias cd..='cd ..'
  113. alias ..=cd..
  114. alias grep='grep $COLOR_OPTIONS'
  115. alias fgrep='fgrep $COLOR_OPTIONS'
  116. alias egrep='egrep -$COLOR_OPTIONS'
  117. # Alias definitions.
  118. # You may want to put all your additions into a separate file like
  119. # ~/.bash_aliases, instead of adding them here directly.
  120. # See /usr/share/doc/bash-doc/examples in the bash-doc package.
  121. if [ -f ~/.bash_aliases ]; then
  122. . ~/.bash_aliases
  123. fi
  124. #PATH=$HOME/.bin:$HOME/DEV/debian-server:$PATH