Skip to content
Snippets Groups Projects
Commit d6db9bac authored by JiriKalvoda's avatar JiriKalvoda
Browse files

Add bash promt features no name and new line

parent cf0c532f
No related branches found
No related tags found
No related merge requests found
......@@ -19,41 +19,55 @@ shopt -s histappend
HISTSIZE=1000
HISTFILESIZE=2000
parse_git_branch() {
promt_parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
rvalue() {
promt_rvalue() {
lastcmd=$?;
if [ $lastcmd -ne 0 ]; then
echo "[$lastcmd]";
fi
exit $lastcmd
}
rvalueUsr() {
promt_NoUser=0
promt_usrCut(){
lastcmd=$?;
usr="\u@\h"
usr=${usr@P}
if [ $promt_NoUser -eq 0 ]; then
if [ $lastcmd -ne 0 ]; then
lastcmdStr="[$lastcmd]";
echo -e "\033[01;31m$lastcmdStr\033[01;32m${usr:${#lastcmdStr}}" | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
printf ${usr:${#lastcmdStr}} | sed -e 's/* \(.*\)/(\1)/'
else
printf $usr | sed -e 's/* \(.*\)/(\1)/'
fi
fi
exit $lastcmd
}
promt_NewLine=0;
promt_MakNewLine(){
if [ $promt_NewLine -ne 0 ]; then
printf '\n$' #| sed -e 's/* \(.*\)/(\1)/'
else
tmp=$usr
printf "\[\033[01;32m$usr\]" | sed -e 's/* \(.*\)/(\1)/'
printf '$' #| sed -e 's/* \(.*\)/(\1)/'
fi
}
#echo -n "$usr"
pNL()
{
if [ $promt_NewLine -eq 0 ]; then
promt_NewLine=1;
else
promt_NewLine=0;
fi
}
usrCut() {
lastcmd=$?;
usr="\u@\h"
usr=${usr@P}
if [ $lastcmd -ne 0 ]; then
lastcmdStr="[$lastcmd]";
printf ${usr:${#lastcmdStr}} | sed -e 's/* \(.*\)/(\1)/'
pNN()
{
if [ $promt_NoUser -eq 0 ]; then
promt_NoUser=1;
else
printf $usr | sed -e 's/* \(.*\)/(\1)/'
promt_NoUser=0;
fi
exit $lastcmd
}
# check the window size after each command and, if necessary,
......@@ -94,7 +108,7 @@ if [ -n "$force_color_prompt" ]; then
fi
#if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]$(rvalue)\[\033[01;32m\]$(usrCut)\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;33m\]$(parse_git_branch)\[\033[00m\]$ \[\033[00m\]'
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]$(promt_rvalue)\[\033[01;32m\]$(promt_usrCut)\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;33m\]$(promt_parse_git_branch)\[\033[00m\]$(promt_MakNewLine) \[\033[00m\]'
# PS1='\e[31m$(rvalue)${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;33m\]$(parse_git_branch)\[\033[00m\]\$ \[\033[00m\] '
# PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;33m\]$(parse_git_branch)\[\033[00m\]$ \[\033[00m\] '
# PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
......
cp bashrc ~/.bashrc
echo "$1" >> ~/.bashrc
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment