├── .gitignore ├── terminal.gif ├── menus ├── darwin.cson └── win32.cson ├── package.json ├── keymaps └── atom-terminal.cson ├── README.md ├── LICENSE.md └── lib └── atom-terminal.coffee /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /terminal.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karan/atom-terminal/HEAD/terminal.gif -------------------------------------------------------------------------------- /menus/darwin.cson: -------------------------------------------------------------------------------- 1 | 'context-menu': 2 | '.platform-darwin .tree-view': [{label: 'Open Terminal at Root', command: 'atom-terminal:open-project-root'}] 3 | -------------------------------------------------------------------------------- /menus/win32.cson: -------------------------------------------------------------------------------- 1 | 'context-menu': 2 | '.platform-win32 .tree-view': [{label: 'Open Terminal at Root', command: 'atom-terminal:open-project-root'}] 3 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "atom-terminal", 3 | "main": "./lib/atom-terminal", 4 | "version": "0.8.1", 5 | "description": "Open terminal in the current file's directory.", 6 | "activationCommands": { 7 | "atom-workspace": [ 8 | "atom-terminal:open", 9 | "atom-terminal:open-project-root" 10 | ] 11 | }, 12 | "repository": "https://github.com/karan/atom-terminal", 13 | "license": "MIT", 14 | "engines": { 15 | "atom": ">0.50.0" 16 | }, 17 | "dependencies": {} 18 | } 19 | -------------------------------------------------------------------------------- /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 | 'atom-workspace': 11 | 'ctrl-shift-t': 'atom-terminal:open' 12 | 'alt-shift-t': 'atom-terminal:open-project-root' 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # atom-terminal 2 | 3 | Open terminal on current file's directory with `ctrl-shift-t`. 4 | 5 | Open a terminal in the project's root directory with `alt-shift-t`. 6 | 7 | Keybindings: `ctrl-shift-t`, `alt-shift-t` 8 | 9 | Install: `apm install atom-terminal` 10 | 11 | Config: 12 | ```coffeescript 13 | "atom-terminal": 14 | # only necessary if standard config doesn't find terminal app 15 | app: "/path/to/your/favorite/terminal" 16 | args: "--useThisOptionWhenLaunchingTerminal" 17 | ``` 18 | 19 | ![atom-terminal](https://raw.github.com/karan/atom-terminal/master/terminal.gif) 20 | -------------------------------------------------------------------------------- /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 | # log the command so we have context if it fails 34 | console.log("atom-terminal executing: ", cmdline) 35 | 36 | # Set the working directory if configured 37 | if setWorkingDirectory 38 | exec cmdline, cwd: dirpath if dirpath? 39 | else 40 | exec cmdline if dirpath? 41 | 42 | 43 | module.exports = 44 | activate: -> 45 | atom.commands.add "atom-workspace", "atom-terminal:open", => @open() 46 | atom.commands.add "atom-workspace", "atom-terminal:open-project-root", => @openroot() 47 | open: -> 48 | editor = atom.workspace.getActivePaneItem() 49 | file = editor?.buffer?.file 50 | filepath = file?.path 51 | if filepath 52 | open_terminal path.dirname(filepath) 53 | openroot: -> 54 | open_terminal pathname for pathname in atom.project.getPaths() 55 | 56 | # Set per-platform defaults 57 | if platform() == 'darwin' 58 | # Defaults for Mac, use Terminal.app 59 | module.exports.config = 60 | app: 61 | type: 'string' 62 | default: 'Terminal.app' 63 | args: 64 | type: 'string' 65 | default: '' 66 | surpressDirectoryArgument: 67 | type: 'boolean' 68 | default: false 69 | setWorkingDirectory: 70 | type: 'boolean' 71 | default: true 72 | MacWinRunDirectly: 73 | type: 'boolean' 74 | default: false 75 | else if platform() == 'win32' 76 | # Defaults for windows, use cmd.exe as default 77 | module.exports.config = 78 | app: 79 | type: 'string' 80 | default: 'C:\\Windows\\System32\\cmd.exe' 81 | args: 82 | type: 'string' 83 | default: '' 84 | surpressDirectoryArgument: 85 | type: 'boolean' 86 | default: false 87 | setWorkingDirectory: 88 | type: 'boolean' 89 | default: true 90 | MacWinRunDirectly: 91 | type: 'boolean' 92 | default: false 93 | else 94 | # Defaults for all other systems (linux I assume), use xterm 95 | module.exports.config = 96 | app: 97 | type: 'string' 98 | default: '/usr/bin/x-terminal-emulator' 99 | args: 100 | type: 'string' 101 | default: '' 102 | surpressDirectoryArgument: 103 | type: 'boolean' 104 | default: false 105 | setWorkingDirectory: 106 | type: 'boolean' 107 | default: true 108 | MacWinRunDirectly: 109 | type: 'boolean' 110 | default: false 111 | --------------------------------------------------------------------------------