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

BASH Return code in promt.

parent 67fe7c41
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,33 @@ rvalue() {
if [ $lastcmd -ne 0 ]; then
echo "[$lastcmd]";
fi
exit $lastcmd
}
rvalueUsr() {
lastcmd=$?;
usr="\u@\h"
usr=${usr@P}
if [ $lastcmd -ne 0 ]; then
lastcmdStr="[$lastcmd]";
echo -e "\033[01;31m$lastcmdStr\033[01;32m${usr:${#lastcmdStr}}" | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
else
tmp=$usr
printf "\[\033[01;32m$usr\]" | sed -e 's/* \(.*\)/(\1)/'
#echo -n "$usr"
fi
}
usrCut() {
lastcmd=$?;
usr="\u@\h"
usr=${usr@P}
if [ $lastcmd -ne 0 ]; then
lastcmdStr="[$lastcmd]";
printf ${usr:${#lastcmdStr}} | sed -e 's/* \(.*\)/(\1)/'
else
printf $usr | sed -e 's/* \(.*\)/(\1)/'
fi
exit $lastcmd
}
# check the window size after each command and, if necessary,
......@@ -67,7 +94,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\]\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;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='\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\]\$ '
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment