windows - How can I open command line prompt from Sublime in windows7 -


i'v created function in vim named opencmd(), used open command line or terminal in vim (and cd in current file path)

func! opencmd()     if has('win32')         let com = '!cmd /c start cd '. expand('%:p:h')     else         let com = '!/usr/bin/gnome-terminal --working-directory=' . expand('%:p:h')     endif     silent execute com endfunc nmap cmd :call opencmd() 

now, want open command line , cd in current file path in sublime (sublime 3 beta). function same opencmd().

and searched question in stackover flow: sublime text 2 - open cmd prompt @ current or project directory (windows)

i did the first guy answered (create cmd, cmd.py , context.sublime-menu). cannot work, cmd operation disabled.

cmd_in_sublime3

is there way can it? in advance!

the answer sublime text 2 - open cmd prompt @ current or project directory (windows) correct.

only 1 step (for me) has changed file name should uppercase. use cmd instead of cmd.


my steps (win7):

  • open folder %appdata%\sublime text 3\packages or click preferences -> browser packages.. in sublime-text-3 beta
  • create folder named cmd (uppercase). path of cmd should %appdata%\sublime text 3\packages\cmd.
  • open folder cmd, , create file, named cmd.py (lowercase), paste context below:
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 file (again), named context.sublime-menu. add context below:
[      { "command": "cmd" } ] 
  • the cmd function work in context menu (right-click). example: open_cmd_in_sublime

of cause, if want open command line command (by 'cmd' example), can add following context default (windows).sublime-keymap file. :

{ "keys": ["c", "m", "d"], "command": "cmd"}

you can open preferences -> key bindings - user


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -