Sublime terminal command line creations producing multiple errors - bash

I have tried numerous articles/git reps/stack overflow posts, nothing is allowing me to simply access sublime through my terminal. I have a /usr/local/bin $PATH and still get the error:
ln: /usr/local/bin/subl: No such file or directory
I ran this block of code that is on the sublime website to get the error:
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl
Some of what I've tried is in the links below; any input or thoughts would be appreciated
https://www.sublimetext.com/docs/3/osx_command_line.html
https://olivierlacan.com/posts/launch-sublime-text-3-from-the-command-line/
Sublime Text subl shortcut not working: ln: /Users/edmundmai/bin/subl: No such file or directory

Related

Sublime Text 3 'subl' command still linked to Sublime Text 2

This is driving me crazy. I'm running OSX and until today I had Sublime Text 2 installed. After installing Sublime Text 3, when I enter the 'subl' command the terminal logs:
Unable to find application named 'Sublime Text 2'
I've tried everything. I've tried
$ rm ~/bin/subl
Then
$ ln -s /Applications/Sublime\ Text\ 3.app/Contents/SharedSupport/bin/subl ~/bin/subl
I've also tried going in to usr directly and removing the subl command. When I do this, the subl command will sometimes work while I remain in one directory, but once I switch directories it goes back to giving me the message
Unable to find application named 'Sublime Text 2'
With Sublime Text 2 I had subl entered as an alias. I also tried going in and unaliasing subl like this:
unalias subl
And I've tried re-creating the alias using
/Applications/Sublime\ Text\ 3.app/Contents/SharedSupport/bin/subl
Again, this will work for a while, but once I change directories it stops working.
Any advice on what to try next? I'm at a loss. I can't understand why it works for a while, then stops working.
Check your .bashrc file, and .bash_profile and see if it's aliased in there. Both of these are in your home directory ~.
nano ~/.bashrc
nano ~/.bash_profile
No need to sudo as you own these documents.

Error installing Sublime text command line functionality

I'm trying to install a symbolic link to Sublime Text (i.e. being able to type "subl Foo.java" into the terminal and launching Sublime). I'm using the following: ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime (which is provided at http://olivierlacan.com/posts/launch-sublime-text-3-from-the-command-line/). However, I'm getting the following error:
ln: /usr/local/bin/sublime: File exists
I've tried editing my path file but nothing seems to be working. Has anyone had a similar problem and have a fix?
It seems like your symlink is still existing, so there is no need to create it twice. Maybe you put the line
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime
into your .bash_profile? if your /usr/local/bin/sublime file exists there is no need for that.

Why do I get "subl: command not found"?

I am trying to access and manipulate the .gitignore file in Sublime via the terminal and I ran into this:
subl .gitignore
-bash: subl: command not found
Why can't it find it?
From the official documentation:
The first task is to make a symlink to subl. 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

Sublime Text 2 and Terminal

So I'm trying to make it so that I can start Sublime Text 2 from the terminal through this command, given by the Sublime Text documentation:
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
But for some reason this is not working. I get this error from my terminal:
ln: /Users/connorblack/bin/subl: No such file or directory
Can anyone help me with this?
Other details: I have SB2 in my Applications folder. I'm trying to do RoR development.
Your problem is that you don't have a ~/bin directory, just do
mkdir ~/bin
And then retry the command, it should work
Note that to use subl from this folder you will still need to add it to your PATH, add this line to your .bashrc or .zshrc:
export PATH=$PATH:/Users/connorblack/bin

Installing Sublime Text's command line tool 'subl' in terminal, permission denied?

I'm tryng to use Sublime Text from the terminal, for example by typing subl.
I'm following the steps from Sublime Text's website:
Setup
The first task is to make a symlink to subl. 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
I keep getting permission denied : ~/bin/subl: Permission Denied
I have been searching around for a similar problem but can't find one that's applicable. Can someone point me to the right direction?
I am assuming that you don't have the bin directory. You can do the following:
cd
mkdir bin
sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
ln -s will create a alias of the subl file in your bin directory and you will be able to run the command.
If this still doesn't work you will have to edit your .bash_profile. You can do it by following commands: (NOTE: For this to work you need to have done the above steps already.)
Open your .bash_profile:
cd // this will get you back to home directory
vim .bash_profile // this will open your .bash_profile file
Edit .bash_profile: press I to get into "insert" mode and add following:
export PATH=$PATH:~/bin
Save and exit. Press Esc to get into command mode:
:wq // saves and close file
exit // exits terminal
Reopen the terminal:
subl --help
That should bring up the help for Sublime Text.
My personal preference for the path to the third-party application-specific symbolic links (e.g. subl, brew, github, mate, etc) is:
/usr/local/bin
Why not /usr/bin/?
/usr/bin is a "sacred" place. It is generally recommended to store static binaries that are maintained by package management systems. subl is not this case.
subl is not stable enough to be stored in /usr/bin with other basic BSD binaries (e.g. find, man, make, etc). You must modify/delete subl symbolic link manually if (a) the developers of Sublime Text Editor decide to change its app name in the future releases (as BBEdit Lite was changed to TextWrangler after version 6.1), or (b) you may simply wish to uninstall Sublime Text Editor.
Therefore, I suggest you execute the following line, assuming /usr/local/bin/ exists:
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
Check whether "~/bin/" is included in the path.
A better options is to create the symlink in /usr/bin directory instead.
sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/bin/subl

Resources