Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ~/.bashrc: executed by bash(1) for non-login shells.
- # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
- # for examples
- # If not running interactively, don't do anything
- [ -z "$PS1" ] && return
- # don't put duplicate lines in the history. See bash(1) for more options
- # ... or force ignoredups and ignorespace
- HISTCONTROL=ignoredups:ignorespace
- # append to the history file, don't overwrite it
- shopt -s histappend
- # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
- HISTSIZE=1000
- HISTFILESIZE=2000
- # check the window size after each command and, if necessary,
- # update the values of LINES and COLUMNS.
- shopt -s checkwinsize
- # make less more friendly for non-text input files, see lesspipe(1)
- [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
- # set variable identifying the chroot you work in (used in the prompt below)
- if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
- debian_chroot=$(cat /etc/debian_chroot)
- fi
- # set a fancy prompt (non-color, unless we know we "want" color)
- case "$TERM" in
- xterm-color) color_prompt=yes;;
- esac
- # uncomment for a colored prompt, if the terminal has the capability; turned
- # off by default to not distract the user: the focus in a terminal window
- # should be on the output of commands, not on the prompt
- force_color_prompt=yes
- if [ -n "$force_color_prompt" ]; then
- if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
- # We have color support; assume it's compliant with Ecma-48
- # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
- # a case would tend to support setf rather than setaf.)
- color_prompt=yes
- else
- color_prompt=
- fi
- fi
- if [ "$color_prompt" = yes ]; then
- PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
- else
- PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
- fi
- unset color_prompt force_color_prompt
- # If this is an xterm set the title to user@host:dir
- case "$TERM" in
- xterm*|rxvt*)
- PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
- ;;
- *)
- ;;
- esac
- # enable color support of ls and also add handy aliases
- if [ -x /usr/bin/dircolors ]; then
- test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
- alias ls='ls --color=auto'
- #alias dir='dir --color=auto'
- #alias vdir='vdir --color=auto'
- alias grep='grep --color=auto'
- alias fgrep='fgrep --color=auto'
- alias egrep='egrep --color=auto'
- fi
- # some more ls aliases
- alias ll='ls -alF'
- alias la='ls -A'
- alias l='ls -CF'
- # Add an "alert" alias for long running commands. Use like so:
- # sleep 10; alert
- 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$//'\'')"'
- # Alias definitions.
- # You may want to put all your additions into a separate file like
- # ~/.bash_aliases, instead of adding them here directly.
- # See /usr/share/doc/bash-doc/examples in the bash-doc package.
- if [ -f ~/.bash_aliases ]; then
- . ~/.bash_aliases
- fi
- # enable programmable completion features (you don't need to enable
- # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
- # sources /etc/bash.bashrc).
- if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
- . /etc/bash_completion
- fi
- ###############x
- # This code was auto generated by with these options:
- # http://andrewray.me/bash-prompt-builder/index.html#git=1&color-git=3&git-prefix=1&color-git-prefix=3&git-ahead=1&color-git-ahead=6b&git-modified=1&color-git-modified=3&git-conflicted=1&color-git-conflicted=1&git-revno=1&color-git-revno=3&color-git-bisect=5&option-submodule=1&color-option-submodule=5&git-ontag=1&color-git-ontag=3&color-hg=5&color-hg-prefix=5&color-hg-modified=5&color-hg-conflicted=1&color-hg-revno=5&color-hg-bisect=3&color-hg-patches=3&svn=1&color-svn=2b&svn-modified=1&color-svn-modified=3b&svn-revno=1&color-svn-revno=Well%2C%20we're%20fucked&option-modified=%E2%9C%8E&option-conflict=%E2%98%A2&color-option-conflict=3&max-conflicted-files=0&option-nobranch=no%20branch!&color-option-nobranch=1&bisecting-text=bisecting&submodule-text=%5Bsubmodule%5D%20
- MAX_CONFLICTED_FILES=0
- DELTA_CHAR="✎"
- CONFLICT_CHAR="☢"
- BISECTING_TEXT="bisecting"
- NOBRANCH_TEXT="no branch!"
- SUBMODULE_TEXT="[submodule] "
- # Colors for prompt
- COLOR_RED=$(tput sgr0 && tput setaf 1)
- COLOR_GREEN=$(tput sgr0 && tput setaf 2)
- COLOR_YELLOW=$(tput sgr0 && tput setaf 3)
- COLOR_BLUE=$(tput sgr0 && tput setaf 4)
- COLOR_MAGENTA=$(tput sgr0 && tput setaf 5)
- COLOR_CYAN=$(tput sgr0 && tput setaf 6)
- COLOR_GRAY=$(tput sgr0 && tput setaf 7)
- COLOR_WHITE=$(tput sgr0 && tput setaf 7 && tput bold)
- COLOR_LIGHTRED=$(tput sgr0 && tput setaf 1 && tput bold)
- COLOR_LIGHTGREEN=$(tput sgr0 && tput setaf 2 && tput bold)
- COLOR_LIGHTYELLOW=$(tput sgr0 && tput setaf 3 && tput bold)
- COLOR_LIGHTBLUE=$(tput sgr0 && tput setaf 4 && tput bold)
- COLOR_LIGHTMAGENTA=$(tput sgr0 && tput setaf 5 && tput bold)
- COLOR_LIGHTCYAN=$(tput sgr0 && tput setaf 6 && tput bold)
- COLOR_RESET=$(tput sgr0)
- _svn_dir=""
- function _svn_check {
- parent=""
- grandparent="."
- while [ -d "$grandparent/.svn" ]; do
- parent=$grandparent
- grandparent="$parent/.."
- done
- if [ ! -z "$parent" ]; then
- _svn_dir=`cd $parent; pwd`
- return 0
- else
- return 1
- fi
- }
- _git_dir=""
- function _git_check {
- _git_dir=`git rev-parse --show-toplevel 2> /dev/null`
- if [[ "$_git_dir" == "" ]]; then
- return 1
- else
- return 0
- fi
- }
- function is_submodule() {
- local parent_git=`cd "$_git_dir/.." && git rev-parse --show-toplevel 2> /dev/null`
- if [[ -n $parent_git ]]; then
- local submodules=`cd $parent_git && git submodule --quiet foreach 'echo $path'`
- for line in $submodules; do
- cd "$parent_git/$line"
- if [[ `pwd` = $_git_dir ]]; then return 0; fi
- done
- fi
- return 1
- }
- dvcs_function="
- # Figure out what repo we are in
- _git_check \
- || _svn_check
- # Build the prompt!
- prompt=\"\"
- # If we are in git ...
- if [ -n \"\$_git_dir\" ]; then
- # find current branch
- gitBranch=\$(git symbolic-ref HEAD 2> /dev/null)
- gitStatus=\`git status\`
- # Figure out current branch, or if we are bisecting, or lost in space
- bisecting=\"\"
- noBranch=\"\"
- if [ -z \"\$gitBranch\" ]; then
- bisect=\$(git rev-list --bisect 2> /dev/null | cut -c1-7)
- if [ -z \"\$bisect\" ]; then
- noBranch=True
- gitBranch=\"\\[\$COLOR_LIGHTRED\\]\$NOBRANCH_TEXT\\[\$COLOR_YELLOW\\]\"
- else
- bisecting=\"\\[\$COLOR_LIGHTGREEN\\]\$BISECTING_TEXT:\"\$bisect\"\\[\$COLOR_YELLOW\\]\"
- gitBranch=\"\"
- fi
- fi
- # changed *tracked* files in local directory?
- gitChange=\$(echo \$gitStatus | ack-grep 'modified:|deleted:|new file:')
- if [ -n \"\$gitChange\" ]; then
- gitChange=\"\\[\$COLOR_LIGHTYELLOW\\] \\[`tput sc`\\] \\[`tput rc`\\]\\[\$DELTA_CHAR\\]\"
- fi
- # output the branch and changed character if present
- prompt=\$prompt\"\\[\$COLOR_YELLOW\\](\"
- if is_submodule; then
- prompt=\$prompt\"\\[\$COLOR_MAGENTA\\]\$SUBMODULE_TEXT\\[\$COLOR_YELLOW\\]\"
- fi
- prefix=\"\\[\$COLOR_LIGHTYELLOW\\]git:\\[\$COLOR_YELLOW\\]\"
- prompt=\$prompt\$prefix\${gitBranch#refs/heads/}\$bisecting
- revNo=\$(git rev-parse HEAD 2> /dev/null | cut -c1-7) || return
- # If bisecting don't output revno
- if [ -z \"\$bisecting\" ] && [ -z \"\$noBranch\" ];then
- prompt=\$prompt\":\$revNo\"
- fi
- tag=\`git describe --tags --exact 2> /dev/null\`
- if [ -n \"\$tag\" ]; then
- prompt=\"\$prompt\\[\$COLOR_YELLOW\\] \\\"\$tag\\\"\\[\$COLOR_YELLOW\\]\"
- fi
- prompt=\$prompt\"\$gitChange\\[\$COLOR_YELLOW\\])\\[\$COLOR_RESET\\]\"
- # How many local commits do you have ahead of origin?
- num=\$(echo \$gitStatus | grep \"Your branch is ahead of\" | awk '{split(\$0,a,\" \"); print a[13];}') || return
- if [ -n \"\$num\" ]; then
- prompt=\$prompt\"\\[\$COLOR_WHITE\\] +\$num\"
- fi
- # any conflicts? (sed madness is to remove line breaks)
- files=\$(git ls-files -u | cut -f 2 | sort -u | sed '$(($MAX_CONFLICTED_FILES+1)),1000d' | sed -e :a -e '\$!N;s/\\\n/, /;ta' -e 'P;D')
- fi
- # If we are in subversion ...
- if [ -n \"\$_svn_dir\" ]; then
- # changed files in local directory? NOTE: This command is the slowest of the bunch
- svnChange=\$(svn status | ack-grep \"^\[M!\]\" | wc -l)
- if [[ \"\$svnChange\" != \" 0\" ]]; then
- svnChange=\"\\[\$COLOR_LIGHTYELLOW\\]\\[`tput sc`\\]\\[`tput rc`\\]\\[\$DELTA_CHAR\\]\"
- else
- svnChange=\"\"
- fi
- # revision number (instead of branch name, silly svn)
- revNo=\`svnversion --no-newline\`
- prompt=\$prompt\"\\[\$COLOR_LIGHTGREEN\\](svn\"
- prompt=\$prompt\"\\[\$COLOR_GRAY\\]:\$revNo\\[\$COLOR_LIGHTGREEN\\] \$svnChange)\\[\$COLOR_RESET\\]\"
- fi
- # Show conflicted files if any
- if [ -n \"\$files\" ]; then
- prompt=\$prompt\" \\[\$COLOR_RED\\](\\[\$COLOR_YELLOW\\]\"
- prompt=\$prompt\"\\[`tput sc`\\] \\[`tput rc`\\]\\[\$COLOR_YELLOW\\]\\[\$CONFLICT_CHAR\\] \"
- prompt=\$prompt\"\\[\$COLOR_RED\\] \${files})\"
- fi
- if [ -n \"\$prompt\" ]; then
- prompt=\$prompt\"\$ \\[\$COLOR_RESET\\]\"
- fi
- echo -e \$prompt"
- # End code auto generated by http://andrewray.me/bash-prompt-builder/index.html
- PS1="$PS1\$(${dvcs_function})"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement