.bashrc 1.2 KB

12345678910111213141516171819202122232425262728
  1. # This might seem backwards when you look at the "Bash startup files" reference
  2. # <http://www.gnu.org/software/bash/manual/bashref.html#Bash-Startup-Files> or
  3. # the "INVOCATION" section in the man page. However, my workflow typically is:
  4. #
  5. # * Open a terminal with four shells in tabs
  6. # * Edit code in Vim, and shell out using ":sh"
  7. #
  8. # The initial four shells are login shells, so they source ~/.bash_profile.
  9. # The shells spawned by Vim are not login shells, but they /are/ interactive.
  10. # They look for .bashrc, but not .bash_profile. Because they are interactive,
  11. # PS1 is set, so I know it is OK to run all the shell initialisation code.
  12. #
  13. # If I were to put the contents of ~/.bash_profile in ~/.bashrc and make the
  14. # former source the latter, I would have to wrap the entire contents of the
  15. # latter in a huge "if [ -n "$PS1" ]; then ... fi" block. That does not really
  16. # help readability, does it?
  17. #
  18. # The difference between a login shell and an interactive non-login shell is
  19. # moot for me, so I consider all interactive shells to be equal and wanting
  20. # the same treatment.
  21. #
  22. # If you're wondering what a non-interactive shell might be, i.e. when PS1
  23. # might not be set, try this:
  24. #
  25. # ssh localhost 'echo "PS1: >$PS1<"'
  26. #
  27. [ -n "$PS1" ] && source ~/.bash_profile;