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.

132 lines
3.4 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
  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 Cya='\[\e[1;36m\]'
  44. local Mag='\[\e[1;95m\]'
  45. local Gra='\[\e[1;30m\]'
  46. PS1=''
  47. #check LXC container name and type
  48. #PS1="${Red}PROD2 ${Yel}\u${R}"
  49. if [ `id -u` -eq 0 ]; then
  50. PS1+="${Red}\u${R}"
  51. PROMPT='$'
  52. else
  53. PS1+="$Gre\u$R"
  54. PROMPT='#'
  55. fi
  56. PS1+="${Gra}@${Gre}\h ${Cya}\w${R}"
  57. if [ $EXIT != 0 ]; then
  58. PS1+="$Mag" # Add red if exit code non 0
  59. else
  60. PS1+="$Gra"
  61. fi
  62. if hash git 2>&-; then
  63. # git command exists
  64. if git rev-parse --git-dir > /dev/null 2>&1; then
  65. # current dir is version controlled
  66. local branch=$(git branch 2> /dev/null | grep -e ^* | cut -d ' ' -f2)
  67. PS1+=" ${R}[${Mag}${branch}${R}|"
  68. local dirty=$(git status -s | wc -l)
  69. if [[ $dirty -ne 0 ]]; then
  70. PS1+="${Mag}…$dirty"
  71. else
  72. local ahead=$(git rev-list --branches --not --remotes |wc -l)
  73. if [[ $ahead -ne 0 ]]; then
  74. PS1+="${Blu}↑${ahead}"
  75. else
  76. PS1+="${Gre}✔"
  77. fi
  78. fi
  79. PS1+="${R}]"
  80. fi
  81. fi
  82. PS1+=" $PROMPT ${R}"
  83. }
  84. PROMPT_COMMAND='__prompt_command' # Func to gen PS1 after CMDs
  85. DEBIAN_BASH_DIR=/opt/debian-bash
  86. # You may uncomment the following lines if you want `ls' to be colorized:
  87. alias ls='ls $COLOR_OPTIONS'
  88. alias ll='ls $COLOR_OPTIONS -l'
  89. alias l=ls
  90. alias la='ls $COLOR_OPTIONS -lA'
  91. alias cd..='cd ..'
  92. alias ..=cd..
  93. alias grep='grep $COLOR_OPTIONS'
  94. alias fgrep='fgrep $COLOR_OPTIONS'
  95. alias egrep='egrep -$COLOR_OPTIONS'
  96. # Alias definitions.
  97. # You may want to put all your additions into a separate file like
  98. # ~/.bash_aliases, instead of adding them here directly.
  99. # See /usr/share/doc/bash-doc/examples in the bash-doc package.
  100. if [ -f ~/.bash_aliases ]; then
  101. . ~/.bash_aliases
  102. fi
  103. #PATH=$HOME/.bin:$HOME/DEV/debian-server:$PATH