From 8e3f9449b303154bdbd01d1433af8c779bf75397 Mon Sep 17 00:00:00 2001 From: Karan Goel Date: Tue, 11 Mar 2014 11:18:20 -0700 Subject: [PATCH] initial package --- .gitignore | 3 +++ LICENSE.md | 20 ++++++++++++++++++++ README.md | 7 +++++++ keymaps/terminal.cson | 11 +++++++++++ lib/terminal.coffee | 18 ++++++++++++++++++ package.json | 14 ++++++++++++++ 6 files changed, 73 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 keymaps/terminal.cson create mode 100644 lib/terminal.coffee create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ade14b9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.DS_Store +npm-debug.log +node_modules diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..5e18ad8 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,20 @@ +Copyright (c) 2014 Karan Goel + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..eca75cc --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# atom-terminal + +Open terminal on current file's directory. + +Keybinding: `ctrl-shift-t` + +![atom-terminal](https://f.cloud.github.com/assets/69169/2290250/c35d867a-a017-11e3-86be-cd7c5bf3ff9b.gif) diff --git a/keymaps/terminal.cson b/keymaps/terminal.cson new file mode 100644 index 0000000..4d2f6e4 --- /dev/null +++ b/keymaps/terminal.cson @@ -0,0 +1,11 @@ +# Keybindings require three things to be fully defined: A selector that is +# matched against the focused element, the keystroke and the command to +# execute. +# +# Below is a basic keybinding which registers on all platforms by applying to +# the root workspace element. + +# For more detailed documentation see +# https://atom.io/docs/latest/advanced/keymaps +'.workspace': + 'ctrl-shift-t': 'terminal:open' diff --git a/lib/terminal.coffee b/lib/terminal.coffee new file mode 100644 index 0000000..61254b3 --- /dev/null +++ b/lib/terminal.coffee @@ -0,0 +1,18 @@ +exec = require('child_process').exec +path = require('path') + +module.exports = + configDefaults: { + app: 'Terminal.app' + args: '' + }, + activate: -> + atom.workspaceView.command "terminal:open", => @open() + + open: -> + filepath = atom.workspaceView.find('.tree-view .selected')?.view()?.getPath?() + if filepath + dirpath = path.dirname(filepath) + app = atom.config.get('terminal.app') + args = atom.config.get('terminal.args') + exec "open -a #{app} #{args} #{dirpath}" if dirpath? diff --git a/package.json b/package.json new file mode 100644 index 0000000..a019709 --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "name": "terminal", + "main": "./lib/terminal", + "version": "0.0.1", + "description": "Open terminal in the current file's directory.", + "activationEvents": ["terminal:open"], + "repository": "https://github.com/karan/atom-terminal", + "license": "MIT", + "engines": { + "atom": ">0.50.0" + }, + "dependencies": { + } +}