My dotfiles. Period.

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