Sublime is Sublime 5

So far we have learned how to install packages and have setup some basic packages for color schemes and for git. In this post we will get better support for the command line as there is lots of useful things that can be done on the command line in a linux system and as a developer you tend to be there often.

To do this bring up the command pallette (ctrl+shift+p) and type install which should bring you to install package. Hit enter and you will get the same popup as when installing the git support in the last post.

In the box type shell turtlestein to install this package https://github.com/misfo/Shell-Turtlestein. This is a very simple package but its also very powerful.

Once it is installed type ctrl+shift+c and a textbox will come up at the bottom of your screen. Any text you type here will be executed. As an example you can try ls -al and you will see the results of your command. This is how you can run arbitrary commands from directly in sublime.

There are however some other features of this command prompt such as being able to take text from in sublime and move them to the command prompt or to take text from the shell and move it to a buffer.

To move text from your command back to a buffer you use the > key trailing your command. As example try ctrl+shift+c then type ps -ax >. This will create a new buffer in sublime with the results of your command. We could even build this way xbuild yoursolution.sln > would bring up a new buffer with the build results but it is not the best way of doing this. This is very useful when writing documentation of say a restful service and interacting via curl

You can also take a document and pipe it to the command (it gets passed as stdin). An example of this can be seen with | wc or | wc > to get the result into a new buffer. The | will either take your selected text in the buffer or the whole text if nothing else is selected.

You can even combine things and do a transformation on your buffer through the command line. An example of this might be | sort | or | transform | which transforms the text then replaces the text within your document.

As you can imagine there are a huge number of possibilities that are now available to you from just interacting with the command line and we will use some of these in the next few posts to do other things that you will need to do on a daily basis.

3 Comments

  1. Posted March 21, 2014 at 9:21 am | Permalink | Reply

    Unfortunately this only runs what is local to your OS, so those commands do not work on Windows (7 in my instance), which is why I use cmder – to get my bash syntax to execute. I might look into installing something else that allows the commands to execute without error…. Unless somebody else has already done this, and can mention what should be installed.

    • Posted March 21, 2014 at 11:32 am | Permalink | Reply

      ah yes ps -ax > for instance will not work in windows as this is a linux command line and its pushing the command to whatever shell you use.

      • Posted March 25, 2014 at 3:12 pm | Permalink

        If you lunch sublime from Git Bash in Windows then all the commands get pushed to it

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 8,258 other followers

%d bloggers like this: