add bash
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
## Enable color support of ls and also add handy aliases
|
||||
# Some colors
|
||||
alias ls='ls -G'
|
||||
alias grep='grep --color=auto'
|
||||
|
||||
# Some utils aliases
|
||||
alias ll='ls -l'
|
||||
alias la='ls -A'
|
||||
alias rmrf='rm -rf'
|
||||
alias gcl='git clone'
|
||||
alias vim='vim -p'
|
||||
|
||||
# Aliases for executing ~/.script scripts
|
||||
alias gitan='sh ~/.script/gitan.sh'
|
||||
alias clean='sh ~/.script/clean.sh'
|
||||
|
||||
## Some export
|
||||
# colored GCC warnings and errors
|
||||
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
|
||||
|
||||
# Used for vim header
|
||||
export VIUSER=xuser
|
||||
export VIMAIL=xuser@student.42.fr
|
||||
|
||||
## Activate and custom bash completion
|
||||
#bind 'TAB:menu-complete'
|
||||
#bind 'set show-all-if-ambiguous on'
|
||||
|
||||
## Setting prompt style
|
||||
# Get current branch in git repo
|
||||
function parse_git_branch() {
|
||||
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
|
||||
if [ ! "${BRANCH}" == "" ]
|
||||
then
|
||||
STAT=`parse_git_dirty`
|
||||
echo " [${BRANCH}${STAT}]"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
# get current status of git repo
|
||||
function parse_git_dirty {
|
||||
status=`git status 2>&1 | tee`
|
||||
dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?"`
|
||||
untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?"`
|
||||
ahead=`echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?"`
|
||||
newfile=`echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?"`
|
||||
renamed=`echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?"`
|
||||
deleted=`echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?"`
|
||||
bits=''
|
||||
if [ "${renamed}" == "0" ] || [ "${newfile}" == "0" ] || [ "${untracked}" == "0" ] || [ "${dirty}" == "0" ]; then
|
||||
bits="+${bits}"
|
||||
fi
|
||||
if [ "${ahead}" == "0" ]; then
|
||||
bits="*${bits}"
|
||||
fi
|
||||
if [ "${deleted}" == "0" ]; then
|
||||
bits="-${bits}"
|
||||
fi
|
||||
if [ ! "${bits}" == "" ]
|
||||
then
|
||||
echo " ${bits}"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
export PS1='`if [ $? = 0 ]; then echo "\[\033[01;36m\]✔"; else echo "\[\033[01;31m\]✘"; fi` \[\033[32m\]\w\[\033[34m\]$(parse_git_branch " %s") \[\033[0m\]>\[\033[00m\] '
|
||||
|
||||
## Lancement des commandes au demarrages
|
||||
Reference in New Issue
Block a user