My dotfiles. Period.

post.bashrc 1.1KB

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