My dotfiles. Period.

post.bashrc 1000B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. ######################################################
  3. ### things to do AFTER host/user-specific settings ###
  4. ######################################################
  5. ### .... ###
  6. ### BASH ###
  7. ### '''' ###
  8. __make_ps1d() {
  9. lastrv=$(cat /var/tmp/bash-rv/$$.lastrv)
  10. if [ $lastrv -gt 0 ];
  11. then
  12. echo "$lastrv"
  13. else
  14. echo ""
  15. fi
  16. }
  17. __save_rv() {
  18. echo $1 > /var/tmp/bash-rv/$$.lastrv
  19. }
  20. make_ps1() {
  21. # these functions must be already defined by ~/.bash/user/*.bashrc
  22. # and ~/.bash/host/*.bashrc
  23. svrc='$(__save_rv $?)'
  24. ps1u=$(make_ps1u)
  25. ps1h=$(make_ps1h)
  26. ps1w="$lblue\w$normal";
  27. ps1G='$(__git_ps1 "(%s)")';
  28. ps1g="$green$ps1G$normal";
  29. ps1D='$(__make_ps1d)';
  30. ps1d="$red$ps1D$normal";
  31. echo "$svrc$ps1u@$ps1h:$ps1w$ps1g$ps1d\$ ";
  32. }
  33. make_ps2() {
  34. echo "$white>$yellow>$lyellow>$normal ";
  35. }
  36. # and use to assemble own PS1
  37. export PS1=$(make_ps1)
  38. export PS2=$(make_ps2)
  39. ### ...... ###
  40. ### OTHERS ###
  41. ### '''''' ###