0

Similar to this question, I have a number of scripts (mostly Bash) that I run on documents frequently and would like to access regardless of the current working directory.

Ideally, I would be able run something like $program foobar without $program being present in the directory, so this needs to tell Bash that the programs are in my path.

Should these files go in the bin subdirectory?

First part of the path is as follows:

echo $PATH
/Users/Chris/.rbenv/shims:/usr/local/bin
Chris
  • 123

1 Answers1

5

This is a cat with many skins, and so has many answers with high degrees of subjectivity, but:

In your home directory, create your own bin subdirectory, which you can then add to your PATH by way of your .profile, for example:

export PATH=$HOME/bin:$PATH

This directs commands to your bin folder in your home directory, and then searches through the rest of your $PATH.

DopeGhoti
  • 76,081
  • With some operating systems just making ${HOME}/bin is enough, because the out-of-the-box shell initialization scripts auto-detect such a directory and alter PATH accordingly. – JdeBP Jan 26 '18 at 07:25
  • 1
    A personal opinion: I prefer $HOME/local/bin so that I can have other "standard" directories (like share and others) under $HOME/local. – Kusalananda Jan 26 '18 at 11:01
  • A cat with many skins, indeed. You say ~/local/mnt, I say ~/mnt. That's the nice thing about this -- whoever is doing it can arrange it in the way that make the most sense personally. – DopeGhoti Jan 26 '18 at 15:17
  • … which leads into https://unix.stackexchange.com/questions/312988/ . – JdeBP Jan 26 '18 at 16:40