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

1 Answer 1

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.

4
  • 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
    Commented Jan 26, 2018 at 7: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
    Commented Jan 26, 2018 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
    Commented Jan 26, 2018 at 15:17
  • … which leads into unix.stackexchange.com/questions/312988 .
    – JdeBP
    Commented Jan 26, 2018 at 16:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .