Skip to content

Bash (shell, not scripting)

Created: 2016-03-01 16:18:51 -0800 Modified: 2020-10-29 11:15:31 -0700

  • ”.” is an alias for “source”, so if you ever see something like ”. venv/bin/activate”, it’s sourcing the “activate” file. Also note: “venv” is a virtual environment for Python that is just going to set the environment for your current shell/project.

[12:40] c17r: it’s because python packages are, by default, stored at the machine/user level, not the project level

  • ”bash —login” or “bash -l” (lowercase L) - starts a bash shell by invoking the various profiles you may have (e.g. /etc/profile, ~/.bash_profile). This is useful when you don’t want to “source” all of those profiles manually.
  • ”type” is a shell built-in that will tell you if something is an alias.
    • type Cd
      • Cd is aliased to `cd’
  • You can clear your command history with “history -c” (you can view it with just “history”)
    • Note that if you type a space before commands, they won’t go into your history.
  • If you find yourself pressing the up arrow to get the last command and then changing the beginning of the command, then you may want to use “!$”, which represents the last argument of the previous command (reference). For example:
    • Old
      • $ git diff t
      • Press up, delete “diff”, change to “add”
      • $ git add t
    • You can instead do this:
      • $ git diff t
      • gitadd! git add !

You’re probably using ”~” in your PATH, so “which NAME_OF_BINARY” doesn’t list it. You can use “$HOME” instead.