How to add a directory to your PATH
Published on: 2025-07-10 05:16:34
I was talking to a friend about how to add a directory to your PATH today. It’s something that feels “obvious” to me since I’ve been using the terminal for a long time, but when I searched for instructions for how to do it, I actually couldn’t find something that explained all of the steps – a lot of them just said “add this to ~/.bashrc ”, but what if you’re not using bash? What if your bash config is actually in a different file? And how are you supposed to figure out which directory to add anyway?
So I wanted to try to write down some more complete directions and mention some of the gotchas I’ve run into over the years.
Here’s a table of contents:
If you’re not sure what shell you’re using, here’s a way to find out. Run this:
ps -p $$ -o pid,comm=
if you’re using bash , it’ll print out 97295 bash
, it’ll print out if you’re using zsh , it’ll print out 97295 zsh
, it’ll print out if you’re using fish, it’ll print out an error like “In fish, please use $fish_pid” ( $$ isn’t val
... Read full article.