1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #!/bin/bash
-
- ######################################################
- ### things to do AFTER host/user-specific settings ###
- ######################################################
-
- ### .... ###
- ### BASH ###
- ### '''' ###
-
- __make_ps1d() {
- lastrv=$(cat /var/tmp/bash-rv/$$.lastrv)
- if [ $lastrv -gt 126 ];
- then
- echo "[0;31m \$"
- elif [ $lastrv -gt 0 ];
- then
- echo "[1;31m \$"
- else
- echo "[1;0m \$"
- fi
- }
-
- __save_rv() {
- echo $1 > /var/tmp/bash-rv/$$.lastrv
- }
-
- make_ps1() {
- # these functions must be already defined by ~/.bash/user/*.bashrc
- # and ~/.bash/host/*.bashrc
- svrc='$(__save_rv $?)'
- ps1u=$(make_ps1u)
- ps1h=$(make_ps1h)
- ps1w="$lblue\w$normal";
- ps1G='$(__git_ps1 "(%s)")';
- ps1g="$green$ps1G$normal";
- ps1D='$(__make_ps1d $?)';
- ps1d="$ps1D";
- echo "$svrc$ps1u@$ps1h:$ps1w$ps1g$ps1d$normal ";
- }
-
- make_ps2() {
- echo "$white>$yellow>$lyellow>$normal ";
- }
-
- # and use to assemble own PS1
- export PS1=$(make_ps1)
- export PS2=$(make_ps2)
-
- ### ...... ###
- ### OTHERS ###
- ### '''''' ###
|