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.

158 lines
4.0 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
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+="${Yel}";;
  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+="${Yel}";;
  71. 'prod')
  72. PS1+="${Red}";;
  73. *)
  74. PS1+="${R}";;
  75. esac
  76. PS1+="\h"
  77. PS1+=" ${Cya}\w${R}"
  78. if hash git 2>&-; then
  79. # git command exists
  80. if git rev-parse --git-dir > /dev/null 2>&1; then
  81. # current dir is version controlled
  82. local branch=$(git branch 2> /dev/null | grep -e ^* | cut -d ' ' -f2)
  83. PS1+=" ${R}[${Mag}${branch}${R}|"
  84. local dirty=$(git status -s | wc -l)
  85. if [[ $dirty -ne 0 ]]; then
  86. PS1+="${Mag}…$dirty"
  87. else
  88. local ahead=$(git rev-list --branches --not --remotes |wc -l)
  89. if [[ $ahead -ne 0 ]]; then
  90. PS1+="${Blu}↑${ahead}"
  91. else
  92. tag_release=`git describe --exact-match --tags $(git log -n1 --pretty='%h')`
  93. PS1+="${Gre}✔${R}|${Blu}${tag_release}"
  94. fi
  95. fi
  96. PS1+="${R}]"
  97. fi
  98. fi
  99. if [ $EXIT != 0 ]; then
  100. PS1+="$Mag" # Add red if exit code non 0
  101. else
  102. PS1+="$Gra"
  103. fi
  104. PS1+=" $PROMPT ${R}"
  105. }
  106. PROMPT_COMMAND='__prompt_command' # Func to gen PS1 after CMDs
  107. DEBIAN_BASH_DIR=/opt/debian-bash
  108. # You may uncomment the following lines if you want `ls' to be colorized:
  109. alias ls='ls $COLOR_OPTIONS'
  110. alias ll='ls $COLOR_OPTIONS -l'
  111. alias lh='ls $COLOR_OPTIONS -lh'
  112. alias la='ls $COLOR_OPTIONS -lA'
  113. alias ltr='ls $COLOR_OPTIONS -ltrh'
  114. alias l=ls
  115. alias cd..='cd ..'
  116. alias ..=cd..
  117. alias grep='grep $COLOR_OPTIONS'
  118. alias fgrep='fgrep $COLOR_OPTIONS'
  119. alias egrep='egrep -$COLOR_OPTIONS'
  120. # Alias definitions.
  121. # You may want to put all your additions into a separate file like
  122. # ~/.bash_aliases, instead of adding them here directly.
  123. # See /usr/share/doc/bash-doc/examples in the bash-doc package.
  124. if [ -f ~/.bash_aliases ]; then
  125. . ~/.bash_aliases
  126. fi
  127. #PATH=$HOME/.bin:$HOME/DEV/debian-server:$PATH