├── .gitignore ├── terminal.gif ├── README.md ├── package.json ├── keymaps └── atom-terminal.cson ├── LICENSE.md └── lib └── atom-terminal.coffee /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /terminal.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dz0ny/atom-terminal/master/terminal.gif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # atom-terminal 2 | 3 | Open terminal on current file's directory with `ctrl-shift-t`. 4 | 5 | Keybinding: `ctrl-shift-t` 6 | 7 | Install: `apm install atom-terminal` 8 | 9 | ![atom-terminal](https://raw.github.com/karan/atom-terminal/master/terminal.gif) 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "atom-terminal", 3 | "main": "./lib/atom-terminal", 4 | "version": "0.4.0", 5 | "description": "Open terminal in the current file's directory.", 6 | "activationEvents": [ 7 | "atom-terminal:open" 8 | ], 9 | "repository": "https://github.com/karan/atom-terminal", 10 | "license": "MIT", 11 | "engines": { 12 | "atom": ">0.50.0" 13 | }, 14 | "dependencies": {} 15 | } 16 | -------------------------------------------------------------------------------- /keymaps/atom-terminal.cson: -------------------------------------------------------------------------------- 1 | # Keybindings require three things to be fully defined: A selector that is 2 | # matched against the focused element, the keystroke and the command to 3 | # execute. 4 | # 5 | # Below is a basic keybinding which registers on all platforms by applying to 6 | # the root workspace element. 7 | 8 | # For more detailed documentation see 9 | # https://atom.io/docs/latest/advanced/keymaps 10 | '.workspace': 11 | 'ctrl-shift-t': 'atom-terminal:open' 12 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Karan Goel 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /lib/atom-terminal.coffee: -------------------------------------------------------------------------------- 1 | exec = require('child_process').exec 2 | path = require('path') 3 | platform = require('os').platform 4 | 5 | ### 6 | Opens a terminal in the given directory, as specefied by the config 7 | ### 8 | open_terminal = (dirpath) -> 9 | # Figure out the app and the arguments 10 | app = atom.config.get('atom-terminal.app') 11 | args = atom.config.get('atom-terminal.args') 12 | 13 | # get options 14 | setWorkingDirectory = atom.config.get('atom-terminal.setWorkingDirectory') 15 | surpressDirArg = atom.config.get('atom-terminal.surpressDirectoryArgument') 16 | runDirectly = atom.config.get('atom-terminal.MacWinRunDirectly') 17 | 18 | # Start assembling the command line 19 | cmdline = "#{app} #{args}" 20 | 21 | # If we do not supress the directory argument, add the directory as an argument 22 | if !surpressDirArg 23 | cmdline += "\"#{dirpath}\"" 24 | 25 | # For mac, we prepend open -a unless we run it directly 26 | if platform() == "darwin" && !runDirectly 27 | cmdline = "open -a " + cmdline 28 | 29 | # for windows, we prepend start unless we run it directly. 30 | if platform() == "win32" && !runDirectly 31 | cmdline = "start " + cmdline 32 | 33 | # Set the working directory if configured 34 | if setWorkingDirectory 35 | exec cmdline, cwd: dirpath if dirpath? 36 | else 37 | exec cmdline if dirpath? 38 | 39 | 40 | module.exports = 41 | activate: -> 42 | atom.workspaceView.command "atom-terminal:open", => @open() 43 | open: -> 44 | filepath = atom.workspaceView.find('.tree-view .selected')?.view()?.getPath?() 45 | if filepath 46 | open_terminal path.dirname(filepath) 47 | 48 | # Set per-platform defaults 49 | if platform() == 'darwin' 50 | # Defaults for Mac, use Terminal.app 51 | module.exports.configDefaults = { 52 | app: 'Terminal.app' 53 | args: '' 54 | surpressDirectoryArgument: false 55 | setWorkingDirectory: false 56 | MacWinRunDirectly: false 57 | } 58 | else if platform() == 'win32' 59 | # Defaults for windows, use cmd.exe as default 60 | module.exports.configDefaults = { 61 | app: 'C:\\Windows\\System32\\cmd.exe' 62 | args: '' 63 | surpressDirectoryArgument: false 64 | setWorkingDirectory: true 65 | MacWinRunDirectly: false 66 | } 67 | else 68 | # Defaults for all other systems (linux I assume), use xterm 69 | module.exports.configDefaults = { 70 | app: '/usr/bin/xterm' 71 | args: '' 72 | surpressDirectoryArgument: true 73 | setWorkingDirectory: true 74 | MacWinRunDirectly: false 75 | } 76 | --------------------------------------------------------------------------------