Advertisement
Guest User

Untitled

a guest
Oct 13th, 2015
633
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.13 KB | None | 0 0
  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.  
  5. export TERM=xterm-256color
  6. export LC_ALL=en_US.UTF-8
  7. export LANG=en_US.UTF-8
  8. export LANGUAGE=en_US.UTF-8
  9.  
  10. bash_prompt_command() {
  11.    # How many characters of the $PWD should be kept
  12.    local pwdmaxlen=25
  13.    # Indicate that there has been dir truncation
  14.    local trunc_symbol=".."
  15.    local dir=${PWD##*/}
  16.    pwdmaxlen=$(( ( pwdmaxlen < ${#dir} ) ? ${#dir} : pwdmaxlen ))
  17.    NEW_PWD=${PWD/#$HOME/\~}
  18.    local pwdoffset=$(( ${#NEW_PWD} - pwdmaxlen ))
  19.    if [ ${pwdoffset} -gt "0" ]
  20.    then
  21.        NEW_PWD=${NEW_PWD:$pwdoffset:$pwdmaxlen}
  22.        NEW_PWD=${trunc_symbol}/${NEW_PWD#*/}
  23.    fi
  24.    NEW_GIT=$(__git_ps1 " (%s) ")
  25. }
  26. bash_prompt() {
  27.         case $TERM in
  28.     xterm*|rxvt*|cyg*)
  29.         local TITLEBAR='\[\033]0;\u:${NEW_PWD}\007\]'
  30.         ;;
  31.     *)
  32.         local TITLEBAR=""
  33.         ;;
  34.         esac
  35.        
  36.     local NONE="\[\033[0m\]"    # unsets color to term's fg color
  37.    
  38.     # regular colors
  39.     local K="\[\033[0;30m\]"    # black
  40.     local R="\[\033[0;31m\]"    # red
  41.     local G="\[\033[0;32m\]"    # green
  42.     local Y="\[\033[0;33m\]"    # yellow
  43.     local B="\[\033[0;34m\]"    # blue
  44.     local M="\[\033[0;35m\]"    # magenta
  45.     local C="\[\033[0;36m\]"    # cyan
  46.     local W="\[\033[0;37m\]"    # white
  47.    
  48.     # empahsized (bolded) colors
  49.     local EMK="\[\033[1;30m\]"
  50.     local EMR="\[\033[1;31m\]"
  51.     local EMG="\[\033[1;32m\]"
  52.     local EMY="\[\033[1;33m\]"
  53.     local EMB="\[\033[1;34m\]"
  54.     local EMM="\[\033[1;35m\]"
  55.     local EMC="\[\033[1;36m\]"
  56.     local EMW="\[\033[1;37m\]"
  57.  
  58.     # background colors
  59.     local BGK="\[\033[40m\]"
  60.     local BGR="\[\033[41m\]"
  61.     local BGG="\[\033[42m\]"
  62.     local BGY="\[\033[43m\]"
  63.     local BGB="\[\033[44m\]"
  64.     local BGM="\[\033[45m\]"
  65.     local BGC="\[\033[46m\]"
  66.     local BGW="\[\033[47m\]"
  67.    
  68.     #special UTF8 characters (Droid for powerline current font)
  69.     local STAR=$(echo -e "\xe2\x98\x85")        #UTF 8 Star
  70.     local BRPT=$(echo -e "\xe2\xae\x80")        #UTF 8 Black Right pointing triangle
  71.     local LOCK=$(echo -e "\xF0\x9F\x94\x92")    #UTF 8 Lock icon
  72.     # colors normal color
  73.     local USERID=$STAR          # icon
  74.     local UC=$EMW               # text color
  75.     local USERBLOCKCOL=$BGR     # block color
  76.     local USERPOINTERCOL=$R     # pointer color
  77.     local USERPOINTERBGCOL=$BGW # pointer background color
  78.    
  79.     # colors root
  80.     [ $UID -eq "0" ] && USERID=$LOCK            # icon
  81.     [ $UID -eq "0" ] && UC=$EMW                 # root's color
  82.     [ $UID -eq "0" ] && USERBLOCKCOL=$BGR       # root's background color
  83.     [ $UID -eq "0" ] && USERPOINTERCOL=$R       # root's pointer color
  84.     [ $UID -eq "0" ] && USERPOINTERBGCOL=$BGW   # root's pointer bg color
  85.    
  86.     PS1="${USERBLOCKCOL}${UC}\[${USERID}\]$TITLEBAR \u@\h ${USERPOINTERCOL}${USERPOINTERBGCOL}\[${BRPT}\] \${NEW_PWD} \\$ ${W}\[${BRPT}\]${NONE} "
  87. }
  88. PROMPT_COMMAND=bash_prompt_command
  89. bash_prompt
  90. unset bash_prompt
  91.  
  92.  
  93. # If not running interactively, don't do anything
  94. case $- in
  95.     *i*) ;;
  96.       *) return;;
  97. esac
  98.  
  99. # don't put duplicate lines or lines starting with space in the history.
  100. # See bash(1) for more options
  101. HISTCONTROL=ignoreboth
  102.  
  103. # append to the history file, don't overwrite it
  104. shopt -s histappend
  105.  
  106. # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
  107. HISTSIZE=1000
  108. HISTFILESIZE=2000
  109.  
  110. # check the window size after each command and, if necessary,
  111. # update the values of LINES and COLUMNS.
  112. shopt -s checkwinsize
  113.  
  114. # If set, the pattern "**" used in a pathname expansion context will
  115. # match all files and zero or more directories and subdirectories.
  116. #shopt -s globstar
  117.  
  118. # make less more friendly for non-text input files, see lesspipe(1)
  119. [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
  120.  
  121. # set variable identifying the chroot you work in (used in the prompt below)
  122. if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
  123.     debian_chroot=$(cat /etc/debian_chroot)
  124. fi
  125.  
  126. # set a fancy prompt (non-color, unless we know we "want" color)
  127. case "$TERM" in
  128.     xterm-color) color_prompt=yes;;
  129. esac
  130.  
  131. # uncomment for a colored prompt, if the terminal has the capability; turned
  132. # off by default to not distract the user: the focus in a terminal window
  133. # should be on the output of commands, not on the prompt
  134. force_color_prompt=yes
  135.  
  136. if [ -n "$force_color_prompt" ]; then
  137.     if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
  138.     # We have color support; assume it's compliant with Ecma-48
  139.     # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
  140.     # a case would tend to support setf rather than setaf.)
  141.     color_prompt=yes
  142.     else
  143.     color_prompt=
  144.     fi
  145. fi
  146.  
  147. # enable color support of ls and also add handy aliases
  148. if [ -x /usr/bin/dircolors ]; then
  149.     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
  150.     alias ls='ls --color=auto'
  151.     #alias dir='dir --color=auto'
  152.     #alias vdir='vdir --color=auto'
  153.  
  154.     alias grep='grep --color=auto'
  155.     alias fgrep='fgrep --color=auto'
  156.     alias egrep='egrep --color=auto'
  157. fi
  158.  
  159. # some more ls aliases
  160. alias ll='ls -alF'
  161. alias la='ls -A'
  162. alias l='ls -CF'
  163.  
  164. # Add an "alert" alias for long running commands.  Use like so:
  165. #   sleep 10; alert
  166. alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
  167.  
  168. # Alias definitions.
  169. # You may want to put all your additions into a separate file like
  170. # ~/.bash_aliases, instead of adding them here directly.
  171. # See /usr/share/doc/bash-doc/examples in the bash-doc package.
  172.  
  173. if [ -f ~/.bash_aliases ]; then
  174.     . ~/.bash_aliases
  175. fi
  176.  
  177. # enable programmable completion features (you don't need to enable
  178. # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
  179. # sources /etc/bash.bashrc).
  180. if ! shopt -oq posix; then
  181.   if [ -f /usr/share/bash-completion/bash_completion ]; then
  182.     . /usr/share/bash-completion/bash_completion
  183.   elif [ -f /etc/bash_completion ]; then
  184.     . /etc/bash_completion
  185.   fi
  186. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement