1. Open file directory
{ "keys": ["ctrl+alt+o"], "command": "open_dir", "args": {"dir": "$file_path", "file": "$file_name"} },
2. Open CMD @ file direcotry
- Plugin
The Shell Turtlestein package also has a command for this:
With that package installed, you can type CTRL+SHIFT+ALT+C to open CMD
- Scriptfile (.py)
- Click the menu
preference
>Browser Packages
in Sublime Text 2. - Create a folder
cmd
in the directory opened in step 1. - Create a python file named
cmd.py
with the following code in thecmd
folder created in step 2.
import os, sublime_plugin
class CmdCommand(sublime_plugin.TextCommand):
def run(self, edit):
file_name=self.view.file_name()
path=file_name.split("\\")
current_driver=path[0]
path.pop()
current_directory="\\".join(path)
command= "cd "+current_directory+" & "+current_driver+" & start cmd"
os.system(command)
- Create a file named
Context.sublime-menu
with the following code in thecmd
folder created in step 2.
[
{ "command": "cmd" }
]
- Reopen Sublime Text 2
Now you can open the Cmd prompt at the current directory in the right-click context menu.
3. Open sublime text with Powershell
I added this to my PowerShell profile:
Set-Alias subl 'C:\Program Files\Sublime Text 2\sublime_text.exe'
4. Set sublime.exe to Path [ref]
On Windows, you can do the same thing using the DOSKEY utility to create "macros" like this: "doskey ls=dir".
You'll need to configure your AutoRun registry value, in "HKEY_CURRENT_USER\Software\Microsoft\Command Processor". I have my AutoRun set to "c:\dev\autorun.bat" which runs a variety of helpful utilities.
e.g. doskey subl="C:\Program Files\Sublime Text 2\sublime_text.exe" $*
- set PATH w/o AutoRun
I've created subl.bat in C:\Program Files\Sublime Text 2 with contents:
start sublime_text.exe %*
Now that I have C:\Program Files\Sublime Text 2 in PATH, I can simply type 'subl folder' and it works wonderfully without having to add anything to autostart.
- set PATH & link
Another idea would be to include
C:\Program Files\Sublime Text 2\
in your PATH, and then run an administrator command prompt:cd "C:\Program Files\Sublime Text 2\"
mklink sublime.exe sublime_text.exe
I've had more success with a hardlink:
mklink /h c:\windows\system32\subl.exe "c:\Program Files\Sublime Text 3\subl.exe"
That will make a symbolic link with the new name. And now you can use it freely:
sublime hello.txt
- set Environment variable w/o mess around Path
I think that is more easy set the Environment variable in Windows.
Then just add a new System variable called SUBLIME_HOME with value "C:\Program Files\Sublime Text 2\" (without quotes) after edit the variable Path adding in the end this value ";%SUBLIME_HOME%"(without quotes).
Restart the git BASH and enjoy, using like this:
$ sublime_text mi-new-file
No comments:
Post a Comment