Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Waiting on the side of the tracks
What is the function of the "subl" command in the code written at 0:51 to 1:06 in the video at this link:
When I try to execute this command in my terminal, it says "-bash: subl: command not found".
Ken AlgerTreehouse Teacher
The subl command the instructors use is a shortcut they have created to launch Sublime Text 2 (their recommended text editor) from the command line. In the Unix world the command is called alias and can be created using:
~$ alias customCommand='orignalCommand' so, if you did alais subl='path/sublime_text' it would create an alias named "subl" pointed to sublime_text. Doing this from the command line only allows you to use this alias during your current login session. To create a permanent alias you can edit .bashrc and put the alias command in there.
Ken. Thanks for your response. Sounds like sound advice.
The terminal seems to accept my command to establish an alias: Richards-Mac-mini:~ ricstr$ alias subl=Macintosh_HD/Applications/Sublime_Text_2
And I am able to make a directory and switch to it: Richards-Mac-mini:~ ricstr$ mkdir -p Source/methods Richards-Mac-mini:~ ricstr$ cd Source/methods
And even create a file: Richards-Mac-mini:methods ricstr$ touch simple_methods.rb
But this is the result: Richards-Mac-mini:methods ricstr$ subl simple_methods.rb -bash: Macintosh_HD/Applications/Sublime_Text_2: No such file or directory Richards-Mac-mini:methods ricstr$ subl simple_methods.rb
What am I doing wrong?
Ken AlgerTreehouse Teacher
Full disclaimer here, I use Windows and Ubuntu Linux much more frequently than Macs, so take what I say for what it is worth. :)
In Ubuntu, here are the steps I took:
1) From the command line, create an alias: alias subl='/home/username/"Sublime Text 2"/sublime_text'
The double quotes were for the folder in which Sublime Text is located and the folder name contains spaces. The file was named sublime_text so I didn't have to use additional quotes.
2) Once I was able to get the alias working for a single session I added the alias to the ~/.bashrc file. In reading about OS X, it seems that the file you would need to edit is ~/.bash_profile. I believe the command in OS X to edit it would be: nano ~/.bash_profile
That's how it worked for me, I would suggest working with the alias subl="" command until you get the path correct to the sublime_text application file. Not sure what it is actually called for Macintosh.
Post back if you have additional questions and I'll see what additional assistance I can be.
Antoine Boillot10,466 Points
I had the same issue with the "subl" command. I typed the following and it worked fine for me then :
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/.rvm/bin/subl