1
0

dev-bash.sh 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # This file gets executed when a user starts a `bash` shell, usually because
  2. # they’ve just started a new Vagrant session with `vagrant ssh`. It configures
  3. # some (but not all) of the commands that you can use.
  4. # Display the installed versions of tools.
  5. # help banner
  6. bash /vagrant/devtools/dev-versions.sh
  7. # Configure the Cool Prompt™ (not actually trademarked).
  8. # The Cool Prompt tells you whether you’re in debug or strict mode, whether
  9. # you have colours configured, and whether your last command failed.
  10. function nonzero_return() { RETVAL=$?; [ $RETVAL -ne 0 ] && echo "$RETVAL "; }
  11. function debug_mode() { [ -n "$EXA_DEBUG" ] && echo "debug "; }
  12. function strict_mode() { [ -n "$EXA_STRICT" ] && echo "strict "; }
  13. function lsc_mode() { [ -n "$LS_COLORS" ] && echo "lsc "; }
  14. function exac_mode() { [ -n "$EXA_COLORS" ] && echo "exac "; }
  15. export PS1="\[\e[1;36m\]\h \[\e[32m\]\w \[\e[31m\]\`nonzero_return\`\[\e[35m\]\`debug_mode\`\[\e[32m\]\`lsc_mode\`\[\e[1;32m\]\`exac_mode\`\[\e[33m\]\`strict_mode\`\[\e[36m\]\\$\[\e[0m\] "
  16. # The ‘debug’ function lets you switch debug mode on and off.
  17. # Turn it on if you need to see exa’s debugging logs.
  18. function debug () {
  19. case "$1" in "on") export EXA_DEBUG=1 ;;
  20. "off") export EXA_DEBUG= ;;
  21. "") [ -n "$EXA_DEBUG" ] && echo "debug on" || echo "debug off" ;;
  22. *) echo "Usage: debug on|off"; return 1 ;; esac; }
  23. # The ‘strict’ function lets you switch strict mode on and off.
  24. # Turn it on if you’d like exa’s command-line arguments checked.
  25. function strict () {
  26. case "$1" in "on") export EXA_STRICT=1 ;;
  27. "off") export EXA_STRICT= ;;
  28. "") [ -n "$EXA_STRICT" ] && echo "strict on" || echo "strict off" ;;
  29. *) echo "Usage: strict on|off"; return 1 ;; esac; }
  30. # The ‘colors’ function sets or unsets the ‘LS_COLORS’ and ‘EXA_COLORS’
  31. # environment variables. There’s also a ‘hacker’ theme which turns everything
  32. # green, which is usually used for checking that all colour codes work, and
  33. # for looking cool while you phreak some mainframes or whatever.
  34. function colors () {
  35. case "$1" in
  36. "ls")
  37. export LS_COLORS="di=34:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43"
  38. export EXA_COLORS="" ;;
  39. "hacker")
  40. export LS_COLORS="di=32:ex=32:fi=32:pi=32:so=32:bd=32:cd=32:ln=32:or=32:mi=32"
  41. export EXA_COLORS="ur=32:uw=32:ux=32:ue=32:gr=32:gw=32:gx=32:tr=32:tw=32:tx=32:su=32:sf=32:xa=32:sn=32:sb=32:df=32:ds=32:uu=32:un=32:gu=32:gn=32:lc=32:lm=32:ga=32:gm=32:gd=32:gv=32:gt=32:xx=32:da=32:in=32:bl=32:hd=32:lp=32:cc=32:" ;;
  42. "off")
  43. export LS_COLORS=
  44. export EXA_COLORS= ;;
  45. "")
  46. [ -n "$LS_COLORS" ] && echo "LS_COLORS=$LS_COLORS" || echo "ls-colors off"
  47. [ -n "$EXA_COLORS" ] && echo "EXA_COLORS=$EXA_COLORS" || echo "exa-colors off" ;;
  48. *) echo "Usage: ls-colors ls|hacker|off"; return 1 ;; esac; }