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.

126 lines
3.2 KiB

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. branch=$(git branch 2> /dev/null | grep -e ^* | cut -d ' ' -f2)
  67. PS1+=" ${R}[${Mag}${branch}${R}|"
  68. dirty=$(git status -s | wc -l)
  69. if [ $dirty == 0 ]; then
  70. PS1+="${Gre}✔"
  71. else
  72. PS1+="${Mag}…$dirty"
  73. fi
  74. PS1+="${R}]"
  75. fi
  76. fi
  77. PS1+=" $PROMPT ${R}"
  78. }
  79. PROMPT_COMMAND='__prompt_command' # Func to gen PS1 after CMDs
  80. DEBIAN_BASH_DIR=/opt/debian-bash
  81. # You may uncomment the following lines if you want `ls' to be colorized:
  82. alias ls='ls $COLOR_OPTIONS'
  83. alias ll='ls $COLOR_OPTIONS -l'
  84. alias l=ls
  85. alias la='ls $COLOR_OPTIONS -lA'
  86. alias cd..='cd ..'
  87. alias ..=cd..
  88. alias grep='grep $COLOR_OPTIONS'
  89. alias fgrep='fgrep $COLOR_OPTIONS'
  90. alias egrep='egrep -$COLOR_OPTIONS'
  91. # Alias definitions.
  92. # You may want to put all your additions into a separate file like
  93. # ~/.bash_aliases, instead of adding them here directly.
  94. # See /usr/share/doc/bash-doc/examples in the bash-doc package.
  95. if [ -f ~/.bash_aliases ]; then
  96. . ~/.bash_aliases
  97. fi
  98. #PATH=$HOME/.bin:$HOME/DEV/debian-server:$PATH