view bashrc @ 64:39b07c5f8785

Add Git and Mercurial support to command prompt
author IBBoard <dev@ibboard.co.uk>
date Tue, 25 Apr 2017 11:42:15 +0100
parents b453b679dd57
children 091d9fc4698b
line wrap: on
line source

if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# Use bash-completion, if available
if [ -f /etc/bash_completion ]; then
	. /etc/bash_completion
fi

# Use a sane editor
export EDITOR=/usr/bin/nano

# Set 256-colour terminal support
export TERM="screen-256color"

#Import aliases
test -s ~/.alias && . ~/.alias || true

# Add sbins to path to make life easier (e.g. /sbin/ifconfig)
export PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH

#Disable man page number prompts - where there's more than one, we normally want the default (user command) version
export MAN_POSIXLY_CORRECT=1

#Disable less history, because do I really search the same things enough to use it across sessions?
export LESSHISTFILE=-

export XDG_CACHE_HOME="$HOME/.cache"

if [ "$PS1" != "" -a "${STARTED_TMUX:-x}" = x -a "${SSH_TTY:-x}" != x ]
then
        STARTED_TMUX=1; export STARTED_TMUX
        sleep 1
        ( (tmux has-session -t remote && tmux attach-session -t remote) || (tmux new-session -s remote) ) && exit 0
        echo "tmux failed to start"
fi

export GTK_IM_MODULE=ibus
export LS_OPTIONS="$LS_OPTIONS -p"

function vcs_status {
	GIT_PS1_SHOWDIRTYSTATE=1
	GIT_PS1_SHOWUPSTREAM=verbose
	. /etc/bash_completion.d/git-prompt.sh
	VCS_EXTRA=$(__git_ps1 "%s")

	if [[ "x$VCS_EXTRA" == "x" ]]; then
		#FIXME: Currently shows "-" even when no incoming changes
		VCS_EXTRA=$(hg prompt "{branch} {-{incoming|count}}{+{outgoing|count}}")
	fi
	if [[ "x$VCS_EXTRA" != "x" ]]; then
		echo -ne ' \033[01;38;5;247m'"($VCS_EXTRA)\033[39m"
	fi
}

# Bold the command prompt and standardise on SUSE format
#export PS1='\[\033[01m\]\u@\h\[\033[00m\]:\[\033[01m\]\w\[\033[00m\]> '
# With colour!
export PS1='\[\033[01;38;5;34m\]\u\[\033[01;38;5;28m\]@\[\033[01;38;5;34m\]\h\[\033[39m\]:\[\033[01;38;5;26m\]\w$(test $PWD != / && echo -n /)\[\033[39m\]$(vcs_status)>\[\033[00m\] '

# Fix "less" highlighting
export LESS_TERMCAP_so=$'\033[30;48;5;247m'
export LESS_TERMCAP_se=$'\033[0m'