Created
May 3, 2012 18:21
-
-
Save okor/2587888 to your computer and use it in GitHub Desktop.
bashrc for ubuntu server
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
# okor's server .bashrc file | |
if [[ -n "$PS1" ]] ; then | |
# | |
#################################################################################################### | |
# Functions ######################################################################################## | |
#################################################################################################### | |
function truncate_pwd | |
{ | |
if [ $HOME == $PWD ] | |
then | |
newPWD="~" | |
elif [ $HOME == ${PWD:0:${#HOME}} ] | |
then | |
newPWD="~${PWD:${#HOME}}" | |
else | |
newPWD=$PWD | |
fi | |
local pwdmaxlen=15 | |
if [ ${#newPWD} -gt $pwdmaxlen ] | |
then | |
local pwdoffset=$(( ${#newPWD} - $pwdmaxlen )) | |
newPWD=".+${newPWD:$pwdoffset:$pwdmaxlen}" | |
fi | |
} | |
# | |
#################################################################################################### | |
# Prompt ########################################################################################### | |
#################################################################################################### | |
PROMPT_COMMAND='truncate_pwd; echo -ne "\033]0;${newPWD}\007"; DIR=`pwd|sed -e "s!$HOME!~!"`; if [ ${#DIR} -gt 30 ]; then CurDir=${DIR:0:12}...${DIR:${#DIR}-15}; else CurDir=$DIR; fi' | |
# | |
#################################################################################################### | |
# History ########################################################################################## | |
#################################################################################################### | |
shopt -s histappend | |
HISTSIZE=100000 | |
HISTFILESIZE=200000 | |
# | |
#################################################################################################### | |
# Exports ########################################################################################## | |
#################################################################################################### | |
export CLICOLOR=1 | |
export LSCOLORS=Gxfxcxdxbxegedabagacad | |
# | |
#################################################################################################### | |
# PS1 line ######################################################################################### | |
#################################################################################################### | |
if [ $UID -eq 0 ]; then | |
PS1='\[\e[0;31m\]@\h\[\e[1;31m\] \W \$\[\e[;0m\] ' | |
else | |
PS1='\e[0;35m\]@\h\e[;0m\] \W \e[0;35m\]\$\[\e[;0m\] ' | |
fi | |
# | |
#################################################################################################### | |
# Alias's ########################################################################################## | |
#################################################################################################### | |
alias ls='ls -Gp' | |
alias grep='grep --color=auto' | |
# | |
#################################################################################################### | |
# For rvm & ruby paths ############################################################################# | |
#################################################################################################### | |
# | |
fi | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment