Simple image host.
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.

.bashrc 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. # ~/.bashrc: executed by bash(1) for non-login shells.
  2. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
  3. # for examples
  4. # If not running interactively, don't do anything
  5. [ -z "$PS1" ] && return
  6. # don't put duplicate lines in the history. See bash(1) for more options
  7. # ... or force ignoredups and ignorespace
  8. HISTCONTROL=ignoredups:ignorespace
  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 variable identifying the chroot you work in (used in the prompt below)
  20. if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
  21. debian_chroot=$(cat /etc/debian_chroot)
  22. fi
  23. export TERM='screen'
  24. # Alias definitions.
  25. # You may want to put all your additions into a separate file like
  26. # ~/.bash_aliases, instead of adding them here directly.
  27. # See /usr/share/doc/bash-doc/examples in the bash-doc package.
  28. if [ -f ~/.bash_aliases ]; then
  29. . ~/.bash_aliases
  30. fi
  31. # enable programmable completion features (you don't need to enable
  32. # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
  33. # sources /etc/bash.bashrc).
  34. if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
  35. . /etc/bash_completion
  36. fi
  37. # interface
  38. # ANSI CODES - SEPARATE MULTIPLE VALUES WITH ;
  39. #
  40. # 0 reset 4 underline
  41. # 1 bold 7 inverse
  42. #
  43. # FG BG COLOR FG BG COLOR
  44. # 30 40 black 34 44 blue
  45. # 31 41 red 35 45 magenta
  46. # 32 42 green 36 46 cyan
  47. # 33 43 yellow 37 47 white
  48. if [[ ! "${prompt_colors[@]}" ]]; then
  49. prompt_colors=(
  50. "0;37" # information color
  51. "0;32" # bracket color
  52. "0;31" # error color
  53. "0;34" # git color
  54. "0;33" # git bracket color
  55. "0;33" # $ color
  56. )
  57. if [[ "$SSH_TTY" ]]; then
  58. # connected via ssh
  59. prompt_colors[1]="1;32"
  60. elif [[ "$USER" == "root" ]]; then
  61. # logged in as root
  62. prompt_colors[1]="1;31"
  63. fi
  64. fi
  65. # Inside a prompt function, run this alias to setup local $c0-$c9 color vars.
  66. alias prompt_getcolors='prompt_colors[9]=; local i; for i in ${!prompt_colors[@]}; do local c$i="\[\e[0;${prompt_colors[$i]}m\]"; done'
  67. # Git status.
  68. function prompt_git() {
  69. prompt_getcolors
  70. local status output flags
  71. status="$(git status 2>/dev/null)"
  72. [[ $? != 0 ]] && return;
  73. output="$(echo "$status" | awk '/# Initial commit/ {print "(init)"}')"
  74. [[ "$output" ]] || output="$(echo "$status" | awk '/# On branch/ {print $4}')"
  75. [[ "$output" ]] || output="$(git branch | perl -ne '/^\* (.*)/ && print $1')"
  76. flags="$(
  77. echo "$status" | awk 'BEGIN {r=""} \
  78. /Changes to be committed:/ {r=r "+"}\
  79. /Changes not staged for commit:/ {r=r "!"}\
  80. /Untracked files:/ {r=r "?"}\
  81. END {print r}'
  82. )"
  83. if [[ "$flags" ]]; then
  84. output="$output$c4:$c3$flags"
  85. fi
  86. echo "$c1-$c3$output$c1$c9"
  87. }
  88. function prompt_command() {
  89. local exit_code=$?
  90. local pad=`printf "%03d" $exit_code`
  91. # If the first command in the stack is prompt_command, no command was run.
  92. # Set exit_code to 0 and reset the stack.
  93. [[ "${prompt_stack[0]}" == "prompt_command" ]] && exit_code=0
  94. prompt_stack=()
  95. # Manually load z here, after $? is checked, to keep $? from being clobbered.
  96. [[ "$(type -t _z)" ]] && _z --add "$(pwd -P 2>/dev/null)" 2>/dev/null
  97. # While the simple_prompt environment var is set, disable the awesome prompt.
  98. [[ "$simple_prompt" ]] && PS1='\n$ ' && return
  99. prompt_getcolors
  100. PS1="\n"
  101. # misc: [cmd#]
  102. #PS1="$PS1$c1[$c0#\#$c1]$c9"
  103. # name: user@host:path
  104. PS1="$PS1$pad $c1\u $c0\w$c1$c9"
  105. # git: [branch:flags]
  106. PS1="$PS1$(prompt_git)"
  107. if [[ "$USER" == "root" ]]; then
  108. PS1="$PS1$c1 #\[\033[0;37m\] "
  109. else
  110. PS1="$PS1$c5 \$\[\033[0;37m\] "
  111. fi
  112. # Update the title with location
  113. echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"
  114. }
  115. PROMPT_COMMAND='prompt_command'