Alias in CMD for Windows for Sublime Text as my editor

If you wanted to accomplish the following:

some specific commands to be executed when you start command prompt.
e.g. cls to clear your command prompt.

or

Like I wanted to use sublime text as my text editor and just type

subl myFile.txt

and have sublime text launch and open that file for editing.

1) Specify an init script in the AutoRun registry value. Create it like this (an expandable string value allows you to use environment variables like %USERPROFILE%)

Open cmd and cope / past this:

reg add "HKCU\Software\Microsoft\Command Processor" /v AutoRun ^
  /t REG_EXPAND_SZ /d "%"USERPROFILE"%\init.cmd" /f

2) Then create a file init.cmd in your profile folder
-> To navigate to your user profile just open run (WinKey + R) and type %USERPROFILE%

And now you can paste your commands in
eg:

@echo off

command_A
command_B
...
cls

For my sublime text purposes i added the following command to my init.cmd

doskey subl="C:\Program Files (x86)\Sublime Text\sublimetext.exe" $*

3) Close and reopen cmd

You can now use:

subl myFile.txt and sublime text will launch with your text file


sources:
http://stackoverflow.com/questions/17404165/how-to-run-a-command-on-command-prompt-startup-in-windows

http://stackoverflow.com/questions/9440639/sublime-text-from-command-line-win7

=)

Comments

Popular Posts