0

I just started reading Michael Hartl's book on Rails and I've run across a problem in the setup phase. Hartl keeps referring to making a file in my home directory, but I'm not quite sure how to do this. For example, when I try to setup the command line for sublime text the instructions tell me to do this: Assuming you've placed Sublime Text 2 in the Applications folder, and that you have a ~/bin directory in your path, you can run:

ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl

My problem is that I don't know how to put a ~/bin directory in my path. I know this is real basic but any help would be greatly appreciation.

ppreyer
  • 6,547
  • 4
  • 20
  • 18

3 Answers3

1

create or edit ~/.profile (works with both bash and zsh)

add the following

export PATH=$PATH:$HOME/bin

The line above is saying, overwrite the PATH environment variable and set it to the previous path plus ~/bin

Now when you try to run a command, bash will look in all the colon separated paths in your PATH environment variable for an executable.

To see your entire PATH, type echo $PATH in a terminal. Or better yet, type env to see all environment variables.

Alexey Kharchenko
  • 1,032
  • 5
  • 10
Kyle
  • 21,978
  • 2
  • 60
  • 61
  • That's the right way to add `~/bin` to your path, but you'll need to create the directory as well. To do that, type `mkdir ~/bin` in the Terminal. – Emily Jun 04 '12 at 19:31
  • Correct. This assumes `~/bin` exists. Thanks Emily. – Kyle Jun 04 '12 at 19:32
  • [see this SO post](http://stackoverflow.com/questions/415403/whats-the-difference-between-bashrc-bash-profile-and-environment) – Kyle Jun 04 '12 at 19:34
  • @Kyle thanks, it's a mess. Each shell is different and I'm using zsh so I think it uses .zshrc always, independent if there is a login or not – Ismael Abreu Jun 04 '12 at 19:41
1

On your terminal

$ mkdir ~/bin
$ sudo ln -s "/Applications/Sublime Text2.app/Contents/SharedSupport/bin/subl" /usr/bin/subl

Edit ~/.base_profile

export PATH=$PATH:~/bin

usage:

open current directory:

subl .

Community
  • 1
  • 1
Gary Lai
  • 6,543
  • 3
  • 17
  • 16
0

In your ~/.bashrc file add to the end:

 PATH="$HOME/bin:$PATH"
Ismael Abreu
  • 16,443
  • 6
  • 61
  • 75