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