Last active
August 29, 2015 14:08
-
-
Save AbrarSyed/8dcc691d031167e21700 to your computer and use it in GitHub Desktop.
This file contains 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
# | |
# ~/.bashrc | |
# | |
# If not running interactively, don't do anything | |
[[ $- != *i* ]] && return | |
################################################## | |
# Fancy PWD display function | |
################################################## | |
# The home directory (HOME) is replaced with a ~ | |
# The last pwdmaxlen characters of the PWD are displayed | |
# Leading partial directory names are striped off | |
# /home/me/stuff -> ~/stuff if USER=me | |
# /usr/share/big_dir_name -> ../share/big_dir_name if pwdmaxlen=20 | |
################################################## | |
bash_prompt_command() { | |
# How many characters of the $PWD should be kept | |
local pwdmaxlen=25 | |
# Indicate that there has been dir truncation | |
local trunc_symbol=".." | |
local dir=${PWD##*/} | |
pwdmaxlen=$(( ( pwdmaxlen < ${#dir} ) ? ${#dir} : pwdmaxlen )) | |
NEW_PWD=${PWD/#$HOME/\~} | |
local pwdoffset=$(( ${#NEW_PWD} - pwdmaxlen )) | |
if [ ${pwdoffset} -gt "0" ] | |
then | |
NEW_PWD=${NEW_PWD:$pwdoffset:$pwdmaxlen} | |
NEW_PWD=${trunc_symbol}/${NEW_PWD#*/} | |
fi | |
} | |
bash_prompt() { | |
case $TERM in | |
xterm*|rxvt*) | |
local TITLEBAR='\[\033]0;\u:${NEW_PWD}\007\]' | |
;; | |
*) | |
local TITLEBAR="" | |
;; | |
esac | |
# Reset | |
local Color_Off='\033[0m' # Text Reset | |
# Regular Colors | |
local Black='\033[0;30m' # Black | |
local Red='\033[0;31m' # Red | |
local Green='\033[0;32m' # Green | |
local Yellow='\033[0;33m' # Yellow | |
local Blue='\033[0;34m' # Blue | |
local Purple='\033[0;35m' # Purple | |
local Cyan='\033[0;36m' # Cyan | |
local White='\033[0;37m' # White | |
# Bold | |
local BBlack='\033[1;30m' # Black | |
local BRed='\033[1;31m' # Red | |
local BGreen='\033[1;32m' # Green | |
local BYellow='\033[1;33m' # Yellow | |
local BBlue='\033[1;34m' # Blue | |
local BPurple='\033[1;35m' # Purple | |
local BCyan='\033[1;36m' # Cyan | |
local BWhite='\033[1;37m' # White | |
# Underline | |
local UBlack='\033[4;30m' # Black | |
local URed='\033[4;31m' # Red | |
local UGreen='\033[4;32m' # Green | |
local UYellow='\033[4;33m' # Yellow | |
local UBlue='\033[4;34m' # Blue | |
local UPurple='\033[4;35m' # Purple | |
local UCyan='\033[4;36m' # Cyan | |
local UWhite='\033[4;37m' # White | |
# Background | |
local On_Black='\033[40m' # Black | |
local On_Red='\033[41m' # Red | |
local On_Green='\033[42m' # Green | |
local On_Yellow='\033[43m' # Yellow | |
local On_Blue='\033[44m' # Blue | |
local On_Purple='\033[45m' # Purple | |
local On_Cyan='\033[46m' # Cyan | |
local On_White='\033[47m' # White | |
# High Intensity | |
local IBlack='\033[0;90m' # Black | |
local IRed='\033[0;91m' # Red | |
local IGreen='\033[0;92m' # Green | |
local IYellow='\033[0;93m' # Yellow | |
local IBlue='\033[0;94m' # Blue | |
local IPurple='\033[0;95m' # Purple | |
local ICyan='\033[0;96m' # Cyan | |
local IWhite='\033[0;97m' # White | |
# Bold High Intensity | |
local BIBlack='\033[1;90m' # Black | |
local BIRed='\033[1;91m' # Red | |
local BIGreen='\033[1;92m' # Green | |
local BIYellow='\033[1;93m' # Yellow | |
local BIBlue='\033[1;94m' # Blue | |
local BIPurple='\033[1;95m' # Purple | |
local BICyan='\033[1;96m' # Cyan | |
local BIWhite='\033[1;97m' # White | |
# High Intensity backgrounds | |
local On_IBlack='\033[0;100m' # Black | |
local On_IRed='\033[0;101m' # Red | |
local On_IGreen='\033[0;102m' # Green | |
local On_IYellow='\033[0;103m' # Yellow | |
local On_IBlue='\033[0;104m' # Blue | |
local On_IPurple='\033[0;105m' # Purple | |
local On_ICyan='\033[0;106m' # Cyan | |
local On_IWhite='\033[0;107m' # White | |
local UC=$Blue # user's colora | |
local PC=$Yellow | |
# stollen from here: http://seanponeil.com/blog/2012/09/13/sexy-solarized-bash-prompt/ | |
parse_git_dirty () { | |
[[ $(git status 2> /dev/null | tail -n 1) != "nothing to commit, working directory clean" ]] && echo "*" | |
} | |
parse_git_branch () { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/(\1$(parse_git_dirty))/" | |
} | |
local COLOR1='\033[01;32m' | |
local COLOR2='\033[01;34m' | |
local COLOR3='\033[00m' | |
PS1="$TITLEBAR[\[${UC}\]\u \[${PC}\]\${NEW_PWD}\[${Color_Off}\]]\[${Green}\]\$(parse_git_branch) \[${Red}\]\\$\[${Color_Off}\] " | |
# without colors: PS1="[\u@\h \${NEW_PWD}]\\$ " | |
# extra backslash in front of \$ to make bash colorize the prompt | |
} | |
PROMPT_COMMAND=bash_prompt_command | |
bash_prompt | |
unset bash_prompt | |
# for colors in man pages... | |
# Less Colors for Man Pages | |
export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking | |
export LESS_TERMCAP_md=$'\E[01;38;5;74m' # begin bold | |
export LESS_TERMCAP_me=$'\E[0m' # end mode | |
export LESS_TERMCAP_se=$'\E[0m' # end standout-mode | |
export LESS_TERMCAP_so=$'\E[38;5;246m' # begin standout-mode - info box | |
export LESS_TERMCAP_ue=$'\E[0m' # end underline | |
export LESS_TERMCAP_us=$'\E[04;38;5;146m' # begin underline | |
export PATH=$PATH:/home/abrarsyed/.gem/ruby/2.1.0/bin:/home/abrarsyed/.scripts | |
# my custom aliases | |
alias wget='wget --content-disposition' | |
alias ls='ls -hF --color=auto' | |
alias grep='grep --color=auto' | |
alias git='hub' | |
alias mkdir='mkdir -p -v' | |
alias sprunge="curl -F 'sprunge=<-' http://sprunge.us" | |
alias cd..='cd ..' | |
alias cd-='cd -' | |
alias pacman='sudo pacman' | |
alias upgrade='sudo pacman -Sy && sudo powerpill -Su && packer -Su --auronly' | |
alias shutdown='sudo shutdown now' | |
alias reboot='sudo reboot' | |
alias vi='vim' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment