I cannot able to connect sublime text 2 from my terminal - terminal

When I am writing open subl in my terminal it's showing The file /user/imtiaz/sublime does not exis can some one please help me for this one thanks

Assuming your account has administrator access, run the following command from Terminal:
sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/bin/subl
The sudo command will ask you to enter your password, which you should do. The symbolic link will be created in /usr/bin, which is already in your path. You should now be able to run
subl filename.ext
and open the filename in Sublime.
If you're just getting started with Sublime, however, I would strongly recommend using Sublime Text 3 instead. It has many major improvements over ST2, and even though it's technically still labeled "Beta", it's rock-solid. I've been using it for over 2 years without any major issues. ST2 has some bugs in it, which will never get fixed. Once installed, the first thing you need to do is install Package Control, which allows you to easily manage plugins. Many plugins now only support ST3, or their ST2 versions are no longer being updated.
If you do install ST3, change the above command to
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/bin/subl
as the app is named Sublime Text.app instead of Sublime Text 2.app.

Related

How to Open a File in Sublime3 from the Command Line on Mac OSX

I was following some intructions online to set up a link so that I can open a file in sublime from my terminal.
I cd into /usr/local/bin I see brew and subl.
Then, I followed the instructions to set up the symbolic link.
In the terminal, I typed ln -s "/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
Then I saw File exists in the terminal
However, when I tried to subl index.html,
I saw this message command not found.
Please advise
Thank you so much for all the answers. I found out that it was an administrative restriction because I was using a work laptop. I resolved it by re-installing sublime text using homebrew. Now, it's working fine.
brew cask install sublime-text
Thanks again.
First up, check your own $PATH by running: echo $PATH. It should return something like this
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
Make sure /usr/local/bin is in the path
Then run
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
Note that the directory sublime text 3 is in is
"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
and not
"/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
Which is what you ran. Hope this helps.
It's not due to administrative restriction and you don't have to re-install sublime text.
As File exists suggests, the file has already exist, that's why your typing doesn't work.
Run rm /usr/local/bin/subl first to delete the exist file.
Then run ln -s "/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl should solve your problem.
Take me for example,
my app is named Sublime Text 3 instead of Sublime Text.
I ran ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl as people suggest.
It didn't work due to the wrong path while the subl file created.
So I had to delete the existed file using rm /usr/local/bin/subl.
Then ran ln -s "/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl instead.
All things work now!!!
I am on El capitan and what worked for me was
running ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
This only works if you check how your extension is named under info
Also on the terminal you can't call sublime because you created it as subl instead so you have to write that in terminal
and then in terminal running subl . (to open a file )

Sublime Text 3 on mac save read only, is not requesting password

I'm trying to save a system file with ST3, /etc/hosts but it throws an error. On another mac machine it ask me for the password and saves normally, but on this new installation it just show this error:
Unable to save ...
Error: ... is readonly px_administrator_copy_file(/tmp/.sublbca.tmp, ...)
Any idas why is not asking for sudo password?
There are two things you can try. First, try opening the file with sudo in the first place. To do this, you'll need to place a symlink to the subl shortcut in /usr/bin:
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/bin/subl
Then, you can just run
sudo subl /etc/hosts
enter your password, and continue as normally.
Second, I'd highly recommend setting
"atomic_save": false
in your user preferences (Sublime Text -> Preferences -> Settings-User). The error you are getting is on a temp file created by atomic saving, and as I explain in the linked answer above, file metadata can get altered or lost when using this "feature", so it's best to just turn it off.

Sublime 3: Subl not working

Before today I had Sublime 2 and 3 on my computer. When I ran the subl command in the terminal it would always open Sublime 2, which I never use anymore. Therefore I got rid of Sublime 2. Now my subl command does not work at all. All I get is subl command not found.
I understand that I have to put a subl binary file into my bin folder. I was just wondering what might be the best way to go about doing that. Any insight on this particular instance would help.
Thanks in advance,
According to their website:
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl
(The command is almost identical to the one for version 2.)
If you have a fresh install of OS X, this will probably fail for you. First, create a ~/bin directory under your home and add it to your path. This will vary by your shell, but if you use bash..
mkdir ~/bin
echo "export PATH=$PATH:~/bin" >> ~/.bash_profile
source ~/.bash_profile
Then you should be able to run the ln command and subl to your hearts content.
As a side note, a simplified version of this can be accomplished with the open command for any app. Try open -a TextEdit hello.txt for similar effect. I've aliased this for a hex editor that didn't offer a CLI launcher like subl.
Try this: (it worked for me)
alias subl="'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl'"
alias nano="subl"
export EDITOR="subl"
Shortly after I posted this question I found the answer. The issue was that because the subl file in my bin or binary folder was tied to Sublime 2, when I uninstalled Sublime 2 it also uninstalled that binary.
All I did was copy the subl file from Sublime 3 into the bin or binary folder. I did have use the terminal in order to get down to the bin folder. Once I opened both folders with the terminal I just copied the subl binary from Sublime 3 to my binary folder.

Sublime Text 2: subl shell command often fails to open files

I have Sublime Text 2 installed on a Mac, and have made a link on the command line as described in the docs.
When opening files from the terminal, as in:
$ subl foo.txt
A Sublime Text window will open, but inside that window foo.txt will only open about one out of every three times or so. I've tried moving the link to a different folder in the path, creating it with sudo, etc., but no luck so far.
Any idea how to fix this?
Had the same problem for a while now. Add the following line to your .bash_profile:
alias subl='subl && sleep 0.1 && subl'
Now you can use subl filename_to_edit to open it.
If you are not sure if you configured subl command correctly, do the following. Run the first command for ST3 or the second for ST2:
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
Make sure that ~/bin is in your $PATH. Then do the first step with .bash_profile.
Finally works as it should! Credit goes to these guys and chrisf for improvement.
I remember running into problems with subl before. And had to come up with a function to see if Sublime is running, if not launch it, see if it loaded. Then use "rmate" bash script and the associated "rsub" Sublime Text Package plugin to load in the specified file. However you should be able to use the OSX open command should work for what you need. I would also give the latest Sublime Text 3 Beta a try.

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