Skip to content

Commit

Permalink
Merge pull request #3 from kyle-ilantzis/master
Browse files Browse the repository at this point in the history
win32
  • Loading branch information
Flynsarmy committed Jul 25, 2014
2 parents ef793d7 + b12e5e3 commit 8bb8a06
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
38 changes: 30 additions & 8 deletions lib/open-terminal-here.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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?
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}"
2 changes: 1 addition & 1 deletion menus/darwin.cson
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'context-menu':
'.platform-darwin .tree-view':
'Open Terminal Here': 'open-terminal-here:open'
'Open Terminal Here': 'open-terminal-here:open'
3 changes: 3 additions & 0 deletions menus/win32.cson
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'context-menu':
'.platform-win32 .tree-view':
'Open Cmd Prompt Here': 'open-terminal-here:open'

0 comments on commit 8bb8a06

Please sign in to comment.