[ADD] Bash configuration files
This commit is contained in:
parent
3544853025
commit
942b21b71d
3
bash/.bash_logout
Normal file
3
bash/.bash_logout
Normal file
|
@ -0,0 +1,3 @@
|
|||
#
|
||||
# ~/.bash_logout
|
||||
#
|
6
bash/.bash_profile
Normal file
6
bash/.bash_profile
Normal file
|
@ -0,0 +1,6 @@
|
|||
#
|
||||
# ~/.bash_profile
|
||||
#
|
||||
|
||||
. ~/.profile
|
||||
[[ -f ~/.bashrc ]] && . ~/.bashrc
|
53
bash/.bash_prompt
Normal file
53
bash/.bash_prompt
Normal file
|
@ -0,0 +1,53 @@
|
|||
# get current status of git repo
|
||||
function __prompt_parse_git_dirty() {
|
||||
git_status=$(git status 2>&1 | tee)
|
||||
dirty=$(echo -n "${git_status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?")
|
||||
untracked=$(echo -n "${git_status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?")
|
||||
ahead=$(echo -n "${git_status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?")
|
||||
newfile=$(echo -n "${git_status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?")
|
||||
renamed=$(echo -n "${git_status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?")
|
||||
deleted=$(echo -n "${git_status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?")
|
||||
bits=''
|
||||
if [ ${renamed} -eq 0 ]; then
|
||||
bits=">${bits}"
|
||||
fi
|
||||
if [ ${ahead} -eq 0 ]; then
|
||||
bits="*${bits}"
|
||||
fi
|
||||
if [ ${newfile} -eq 0 ]; then
|
||||
bits="+${bits}"
|
||||
fi
|
||||
if [ ${untracked} -eq 0 ]; then
|
||||
bits="?${bits}"
|
||||
fi
|
||||
if [ ${deleted} -eq 0 ]; then
|
||||
bits="x${bits}"
|
||||
fi
|
||||
if [ ${dirty} -eq 0 ]; then
|
||||
bits="!${bits}"
|
||||
fi
|
||||
if [ -z "$bits" ]; then
|
||||
echo ""
|
||||
else
|
||||
echo " ${bits}"
|
||||
fi
|
||||
}
|
||||
|
||||
# get current branch in git repo
|
||||
function __prompt_parse_git_branch() {
|
||||
git_branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
|
||||
if [ -z "${git_branch}" ]; then
|
||||
echo ""
|
||||
else
|
||||
git_stat=$(__prompt_parse_git_dirty)
|
||||
echo "[${git_branch}${git_stat}]"
|
||||
fi
|
||||
}
|
||||
|
||||
# Display return value only when non-zero
|
||||
function __prompt_nonzero_return() {
|
||||
RETVAL=$?
|
||||
[ $RETVAL -ne 0 ] && echo "[$RETVAL]"
|
||||
}
|
||||
|
||||
export PS1="\e[31m\`__prompt_nonzero_return\`\e[m[\[\e[32m\]\u\[\e[m\]@\[\e[34m\]\h\[\e[36m\] \w\[\e[m\]]\e[35m\`__prompt_parse_git_branch\`\e[m\n42sh$ "
|
62
bash/.bashrc
Normal file
62
bash/.bashrc
Normal file
|
@ -0,0 +1,62 @@
|
|||
#
|
||||
# ~/.bashrc
|
||||
#
|
||||
|
||||
# If not running interactively, don't do anything
|
||||
[[ $- != *i* ]] && return
|
||||
|
||||
# Make colorcoding available for everyone
|
||||
|
||||
Black='\e[0;30m' # Black
|
||||
Red='\e[0;31m' # Red
|
||||
Green='\e[0;32m' # Green
|
||||
Yellow='\e[0;33m' # Yellow
|
||||
Blue='\e[0;34m' # Blue
|
||||
Purple='\e[0;35m' # Purple
|
||||
Cyan='\e[0;36m' # Cyan
|
||||
White='\e[0;37m' # White
|
||||
|
||||
# Bold
|
||||
BBlack='\e[1;30m' # Black
|
||||
BRed='\e[1;31m' # Red
|
||||
BGreen='\e[1;32m' # Green
|
||||
BYellow='\e[1;33m' # Yellow
|
||||
BBlue='\e[1;34m' # Blue
|
||||
BPurple='\e[1;35m' # Purple
|
||||
BCyan='\e[1;36m' # Cyan
|
||||
BWhite='\e[1;37m' # White
|
||||
|
||||
# Background
|
||||
On_Black='\e[40m' # Black
|
||||
On_Red='\e[41m' # Red
|
||||
On_Green='\e[42m' # Green
|
||||
On_Yellow='\e[43m' # Yellow
|
||||
On_Blue='\e[44m' # Blue
|
||||
On_Purple='\e[45m' # Purple
|
||||
On_Cyan='\e[46m' # Cyan
|
||||
On_White='\e[47m' # White
|
||||
|
||||
NC="\e[m" # Color Reset
|
||||
|
||||
|
||||
# new alert text
|
||||
ALERT=${BWhite}${On_Red} # Bold White on red background
|
||||
|
||||
# Display the computer's name in ASCII art
|
||||
cat /etc/issue
|
||||
|
||||
# FIXME: those files should be in some folders...
|
||||
# Import my aliases
|
||||
source ~/.aliases
|
||||
|
||||
# Import some useful functions
|
||||
source ~/.functions
|
||||
|
||||
# Import my profile on interactive shells
|
||||
source ~/.profile
|
||||
|
||||
# Import my prompt
|
||||
source ~/.bash_prompt
|
||||
|
||||
# set PATH so it includes user's private bin directories
|
||||
PATH="$HOME/bin:$HOME/.local/bin:$PATH"
|
Loading…
Reference in a new issue