diff --git a/lib/open-terminal-here.coffee b/lib/open-terminal-here.coffee index d12d169..6115381 100644 --- a/lib/open-terminal-here.coffee +++ b/lib/open-terminal-here.coffee @@ -2,18 +2,40 @@ exec = require("child_process").exec path = require('path') module.exports = + configDefaults: { app: 'Terminal.app' args: '' + win32App: 'cmd' + win32Args: '' }, + activate: -> - atom.workspaceView.command "open-terminal-here:open", (event) => - @open() + atom.workspaceView.command "open-terminal-here:open", => @open() open: -> - filepath = atom.workspaceView.find('.tree-view .selected')?.view()?.getPath?() - if filepath - dirpath = path.dirname(filepath) - app = atom.config.get('open-terminal-here.app') - args = atom.config.get('open-terminal-here.args') - exec "open -a #{app} #{args} #{dirpath}" if dirpath? \ No newline at end of file + isDarwin = document.body.classList.contains("platform-darwin") + isWin32 = document.body.classList.contains("platform-win32") + + selectedView = atom.workspaceView.find('.tree-view .selected')?.view() + isDir = selectedView?.hasClass("directory") + isFile = selectedView?.hasClass("file") + thepath = selectedView?.getPath() + dirpath = if isFile then path.dirname thepath else thepath + + return if not dirpath + + if isDarwin + @openDarwin dirpath + else #isWin32 + @openWin32 dirpath + + openDarwin: (dirpath) -> + app = atom.config.get('open-terminal-here.app') + args = atom.config.get('open-terminal-here.args') + exec "open -a #{app} #{args} #{dirpath}" + + openWin32: (dirpath) -> + app = atom.config.get('open-terminal-here.win32App') + args = atom.config.get('open-terminal-here.win32Args') + exec "start /D #{dirpath} #{app} #{args}" diff --git a/menus/darwin.cson b/menus/darwin.cson index 9fd1dae..3372d33 100644 --- a/menus/darwin.cson +++ b/menus/darwin.cson @@ -1,3 +1,3 @@ 'context-menu': '.platform-darwin .tree-view': - 'Open Terminal Here': 'open-terminal-here:open' \ No newline at end of file + 'Open Terminal Here': 'open-terminal-here:open' diff --git a/menus/win32.cson b/menus/win32.cson new file mode 100644 index 0000000..0fe433c --- /dev/null +++ b/menus/win32.cson @@ -0,0 +1,3 @@ +'context-menu': + '.platform-win32 .tree-view': + 'Open Cmd Prompt Here': 'open-terminal-here:open'