Created
June 16, 2011 23:09
-
-
Save fxthomas/1030532 to your computer and use it in GitHub Desktop.
BashRC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This .bashrc script was developped by François-Xavier Thomas. | |
# You are free to copy, adapt or modify it. | |
# If you do so, however, leave my name somewhere in the credits, I'd appreciate it ;) | |
# | |
# Although some parts were ripped off various sources over the internet, I gathered them and made my own there. | |
# I try to keep up with these sources as I add them, but if you're the author and don't like it, just message me on twitter @fxvisual | |
# 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 | |
export HISTCONTROL=ignoredups | |
# ... and ignore same sucessive entries. | |
export HISTCONTROL=ignoreboth | |
# 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 "$(lesspipe)" | |
# 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 color support of ls | |
if [ "$TERM" != "dumb" ]; then | |
eval "`dircolors -b`" | |
alias ls='ls -h --color=auto' | |
fi | |
# Add stuff to the path | |
export PATH=$PATH:$HOME/Scripts:/usr/local/cuda/bin:/opt/matlab/bin | |
# 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 ]; then | |
. /etc/bash_completion | |
fi | |
# Set vi-style command line editing | |
#set -o vi | |
# Set VIM as the default editor | |
export EDITOR="vim" | |
# Setup automatic screen session at login (very useful!) | |
# From: http://geekscrap.com/2010/02/using-screen-as-your-login-shell/ | |
if [ ${SHLVL} -eq 1 ]; then | |
((SHLVL+=1)); export SHLVL | |
exec screen -R -e "^Aa" ${SHELL} -l | |
fi | |
# Set prompt variables | |
# From: http://www.jonmaddox.com/2008/03/13/show-your-git-branch-name-in-your-prompt/ | |
function setPromptVars { | |
P_GITBRANCH=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' -e 's/^/[git:/' -e 's/$/]/') | |
P_HGTIP=$(hg branch 2> /dev/null | sed -e 's/^/[hg:/' -e 's/$/]/') | |
} | |
# Set prompt | |
function setPromptText { | |
local RETCODE=$? | |
local YELLOW="\[\033[0;33m\]" | |
local BLUE="\[\033[0;34m\]" | |
local LIGHT_BLUE="\[\033[0;36m\]" | |
local RED="\[\033[0;31m\]" | |
local LIGHT_RED="\[\033[1;31m\]" | |
local GREEN="\[\033[0;32m\]" | |
local LIGHT_GREEN="\[\033[1;32m\]" | |
local WHITE="\[\033[1;37m\]" | |
local LIGHT_GRAY="\[\033[0;37m\]" | |
local NORMAL="\[\033[0m\]" | |
case $TERM in | |
xterm*) | |
TITLEBAR='\[\033]0;\u@\h:\w\007\]' | |
;; | |
*) | |
TITLEBAR="" | |
;; | |
esac | |
local P_USER="\u" | |
local P_HOST="\h" | |
local P_DATE="\d" | |
local P_TIME="\t" | |
local P_PWD="\w" | |
local P_COUNT="\#" | |
local P_RETCODE="" | |
if [ $RETCODE -ne 0 ]; then | |
P_RETCODE="[$RETCODE]" | |
fi | |
setPromptVars | |
PS1="$LIGHT_BLUE${P_USER}$GREEN@$LIGHT_BLUE${P_HOST}$YELLOW${P_GITBRANCH}${P_HGTIP}$GREEN [${P_DATE}/${P_TIME}] [${P_PWD}] [${P_COUNT}] $RED${P_RETCODE}$NORMAL\n" | |
PS2='> ' | |
PS4='+ ' | |
} | |
# Set 'setPromptText' to be executed on each new prompt | |
# See: http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x264.html | |
export PROMPT_COMMAND=setPromptText |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment