├── .gitignore ├── resources ├── edit.png ├── icon.png └── terminal.png ├── screenshots ├── ss1.png └── ss2.png ├── .vscodeignore ├── .vscode ├── extensions.json └── launch.json ├── jsconfig.json ├── CHANGELOG.md ├── .eslintrc.json ├── test ├── extension.test.js └── index.js ├── LICENSE ├── extension.js ├── package.json ├── vsc-extension-quickstart.md ├── README.md └── commands.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .vscode-test/ 3 | *.vsix 4 | archive 5 | PAT.txt -------------------------------------------------------------------------------- /resources/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabhdaware/vscode-terminal-manager/HEAD/resources/edit.png -------------------------------------------------------------------------------- /resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabhdaware/vscode-terminal-manager/HEAD/resources/icon.png -------------------------------------------------------------------------------- /screenshots/ss1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabhdaware/vscode-terminal-manager/HEAD/screenshots/ss1.png -------------------------------------------------------------------------------- /screenshots/ss2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabhdaware/vscode-terminal-manager/HEAD/screenshots/ss2.png -------------------------------------------------------------------------------- /resources/terminal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabhdaware/vscode-terminal-manager/HEAD/resources/terminal.png -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | test/** 4 | .gitignore 5 | vsc-extension-quickstart.md 6 | **/jsconfig.json 7 | **/*.map 8 | **/.eslintrc.json 9 | screenshots 10 | archive 11 | PAT.txt -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "dbaeumer.vscode-eslint" 6 | ] 7 | } -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es6", 5 | "checkJs": false, /* Typecheck .js files. */ 6 | "lib": [ 7 | "es6" 8 | ] 9 | }, 10 | "exclude": [ 11 | "node_modules" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ### 1.0.0 - 1.0.4 4 | 5 | - Initial Release of Terminal Manager and Minor Updates. 6 | 7 | ### 1.0.5 8 | 9 | - Fixed Path error that was thrown in Ubuntu when edit button was clicked 10 | 11 | ### 1.0.6 12 | 13 | - shellArgs can be added to terminal (Thanks to [#PR5](https://github.com/saurabhdaware/vscode-terminal-manager/pull/5) by [4a-42](https://github.com/4a-42)) 14 | - added default terminals.json configs for linux and osx 15 | 16 | 17 | ---- -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": false, 4 | "commonjs": true, 5 | "es6": true, 6 | "node": true 7 | }, 8 | "parserOptions": { 9 | "ecmaFeatures": { 10 | "jsx": true 11 | }, 12 | "sourceType": "module" 13 | }, 14 | "rules": { 15 | "no-const-assign": "warn", 16 | "no-this-before-super": "warn", 17 | "no-undef": "warn", 18 | "no-unreachable": "warn", 19 | "no-unused-vars": "warn", 20 | "constructor-super": "warn", 21 | "valid-typeof": "warn" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/extension.test.js: -------------------------------------------------------------------------------- 1 | /* global suite, test */ 2 | 3 | // 4 | // Note: This example test is leveraging the Mocha test framework. 5 | // Please refer to their documentation on https://mochajs.org/ for help. 6 | // 7 | 8 | // The module 'assert' provides assertion methods from node 9 | const assert = require('assert'); 10 | 11 | // You can import and use all API from the 'vscode' module 12 | // as well as import your extension to test it 13 | // const vscode = require('vscode'); 14 | // const myExtension = require('../extension'); 15 | 16 | // Defines a Mocha test suite to group tests of similar kind together 17 | suite("Extension Tests", function() { 18 | 19 | // Defines a Mocha unit test 20 | test("Something 1", function() { 21 | assert.equal(-1, [1, 2, 3].indexOf(5)); 22 | assert.equal(-1, [1, 2, 3].indexOf(0)); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "runtimeExecutable": "${execPath}", 13 | "args": [ 14 | "--extensionDevelopmentPath=${workspaceFolder}" 15 | ] 16 | }, 17 | { 18 | "name": "Extension Tests", 19 | "type": "extensionHost", 20 | "request": "launch", 21 | "runtimeExecutable": "${execPath}", 22 | "args": [ 23 | "--extensionDevelopmentPath=${workspaceFolder}", 24 | "--extensionTestsPath=${workspaceFolder}/test" 25 | ] 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | // 2 | // PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING 3 | // 4 | // This file is providing the test runner to use when running extension tests. 5 | // By default the test runner in use is Mocha based. 6 | // 7 | // You can provide your own test runner if you want to override it by exporting 8 | // a function run(testsRoot: string, clb: (error: Error, failures?: number) => void): void 9 | // that the extension host can call to run the tests. The test runner is expected to use console.log 10 | // to report the results back to the caller. When the tests are finished, return 11 | // a possible error to the callback or null if none. 12 | 13 | const testRunner = require('vscode/lib/testrunner'); 14 | 15 | // You can directly control Mocha options by configuring the test runner below 16 | // See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options 17 | // for more info 18 | testRunner.configure({ 19 | ui: 'tdd', // the TDD UI is being used in extension.test.js (suite, test, etc.) 20 | useColors: true // colored output from test results 21 | }); 22 | 23 | module.exports = testRunner; 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Saurabh Daware 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /extension.js: -------------------------------------------------------------------------------- 1 | // The module 'vscode' contains the VS Code extensibility API 2 | // Import the module and reference it with the alias vscode in your code below 3 | const fs = require('fs'); 4 | const TerminalManager = require('./commands.js') 5 | // this method is called when your extension is activated 6 | // your extension is activated the very first time the command is executed 7 | 8 | /** 9 | * @param {vscode.ExtensionContext} context 10 | */ 11 | 12 | // This is supperr hacky way of creating Trees I got no fking clue how to use it in real. 13 | 14 | function activate(context) { 15 | let terminalManager = new TerminalManager(context); 16 | 17 | terminalManager.loadTerminals() 18 | .then(()=>{ 19 | return terminalManager.loadCommands(); 20 | }) 21 | .then((subscriptions) => { 22 | fs.watchFile(context.globalStoragePath+'//terminals.json',function(event){ 23 | console.log(event); 24 | for(let disposable of subscriptions){ 25 | disposable.dispose(); 26 | } 27 | // tree.dispose(); 28 | terminalManager.loadTerminals(); 29 | terminalManager.loadCommands(); 30 | }) 31 | }) 32 | } 33 | exports.activate = activate; 34 | 35 | // this method is called when your extension is deactivated 36 | function deactivate() {} 37 | 38 | module.exports = { 39 | activate, 40 | deactivate 41 | } 42 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "terminal-manager", 3 | "displayName": "Terminal Manager", 4 | "description": "Choose which terminal to use in single click and switch between multiple terminals. ", 5 | "version": "1.0.6", 6 | "publisher": "saurabh", 7 | "author": { 8 | "name": "saurabhdaware" 9 | }, 10 | "icon": "resources/icon.png", 11 | "engines": { 12 | "vscode": "^1.34.0" 13 | }, 14 | "categories": [ 15 | "Other" 16 | ], 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/saurabhdaware/vscode-terminal-manager.git" 20 | }, 21 | "license": "MIT", 22 | "homepage": "https://github.com/saurabhdaware/vscode-terminal-manager/blob/master/README.md", 23 | "bugs": { 24 | "url": "https://github.com/saurabhdaware/vscode-terminal-manager/issues", 25 | "email": "saurabhdaware99@gmail.com" 26 | }, 27 | "keywords": [ 28 | "Terminal Manager", 29 | "Multiple Terminal", 30 | "Switch Terminal", 31 | "Ubuntu Terminal", 32 | "Windows Terminal" 33 | ], 34 | "activationEvents": [ 35 | "onView:terminal-manager" 36 | ], 37 | "main": "./extension.js", 38 | "contributes": { 39 | "viewsContainers": { 40 | "activitybar": [ 41 | { 42 | "id": "terminal-manager", 43 | "title": "Terminal Manager", 44 | "icon": "resources/terminal.png" 45 | } 46 | ] 47 | }, 48 | "views": { 49 | "terminal-manager": [ 50 | { 51 | "id": "terminal-manager", 52 | "name": "Terminals" 53 | } 54 | ] 55 | }, 56 | "commands": [ 57 | { 58 | "command": "extension.editTerminals", 59 | "title": "Edit Terminals", 60 | "icon":{ 61 | "dark": "resources/edit.png", 62 | "light": "resources/edit.png" 63 | } 64 | } 65 | ], 66 | "menus":{ 67 | "view/title": [ 68 | { 69 | "command":"extension.editTerminals", 70 | "when":"view == terminal-manager", 71 | "group":"navigation" 72 | } 73 | ] 74 | } 75 | }, 76 | "scripts": { 77 | "postinstall": "node ./node_modules/vscode/bin/install", 78 | "test": "node ./node_modules/vscode/bin/test" 79 | }, 80 | "devDependencies": { 81 | "typescript": "^3.3.1", 82 | "vscode": "^1.1.28", 83 | "eslint": "^5.13.0", 84 | "@types/node": "^10.12.21", 85 | "@types/mocha": "^2.2.42" 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /vsc-extension-quickstart.md: -------------------------------------------------------------------------------- 1 | # Welcome to your VS Code Extension 2 | 3 | ## What's in the folder 4 | 5 | * This folder contains all of the files necessary for your extension. 6 | * `package.json` - this is the manifest file in which you declare your extension and command. 7 | * The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin. 8 | * `extension.js` - this is the main file where you will provide the implementation of your command. 9 | * The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`. 10 | * We pass the function containing the implementation of the command as the second parameter to `registerCommand`. 11 | 12 | ## Get up and running straight away 13 | 14 | * Press `F5` to open a new window with your extension loaded. 15 | * Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`. 16 | * Set breakpoints in your code inside `extension.js` to debug your extension. 17 | * Find output from your extension in the debug console. 18 | 19 | ## Make changes 20 | 21 | * You can relaunch the extension from the debug toolbar after changing code in `extension.js`. 22 | * You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. 23 | 24 | ## Explore the API 25 | 26 | * You can open the full set of our API when you open the file `node_modules/vscode/vscode.d.ts`. 27 | 28 | ## Run tests 29 | 30 | * Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Extension Tests`. 31 | * Press `F5` to run the tests in a new window with your extension loaded. 32 | * See the output of the test result in the debug console. 33 | * Make changes to `test/extension.test.js` or create new test files inside the `test` folder. 34 | * By convention, the test runner will only consider files matching the name pattern `**.test.js`. 35 | * You can create folders inside the `test` folder to structure your tests any way you want. 36 | 37 | ## Go further 38 | 39 | * [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VSCode extension marketplace. 40 | * Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration). 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ![](resources/terminal.png) Terminal Manager 2 | 3 | Terminal Manager is a visual studio code extension to switch between various terminals. 4 | 5 | [![Current version of Terminal Manager](https://vsmarketplacebadge.apphb.com/version-short/saurabh.terminal-manager.svg)](https://marketplace.visualstudio.com/items?itemName=saurabh.terminal-manager) [![Current version of Terminal Manager](https://vsmarketplacebadge.apphb.com/downloads/saurabh.terminal-manager.svg)](https://marketplace.visualstudio.com/items?itemName=saurabh.terminal-manager) [![Current version of Terminal Manager](https://vsmarketplacebadge.apphb.com/rating-short/saurabh.terminal-manager.svg)](https://marketplace.visualstudio.com/items?itemName=saurabh.terminal-manager) 6 | 7 | [![Install extension button](https://res.cloudinary.com/saurabhdaware/image/upload/v1564401766/saurabhdaware.in/otherAssets/iebutton.png)](https://marketplace.visualstudio.com/items?itemName=saurabh.terminal-manager) 8 | 9 | ## Features 10 | 11 | By default vscode lets us define only one link of terminal from settings. 12 | 13 | Using this extension you can provide an array of terminals and then you can switch between them from a new Terminal icon in activity bar. 14 | 15 | ![](screenshots/ss1.png) 16 | ![](screenshots/ss2.png) 17 | 18 | ## Extension Settings 19 | 20 | Click the edit icon ![](resources/edit.png) in Terminal Manager activity bar to edit the terminal settings. 21 | 22 | Here's what sample terminals.json looks like. (Note : Ubuntu configs will only work if you have wsl installed in your windows) 23 | 24 | ### In Windows : 25 | ```json 26 | [ 27 | { 28 | "label":"Windows", 29 | "shellPath":"C://Windows//System32//cmd.exe", 30 | "shellArgs":[ 31 | "/K", 32 | "echo Heya!" 33 | ] 34 | }, 35 | { 36 | "label":"Ubuntu", 37 | "shellPath":"C://Windows//System32//bash.exe" 38 | } 39 | ] 40 | ``` 41 | 42 | ### In Linux and OSX: 43 | ```json 44 | [ 45 | { 46 | "label":"Login bash", 47 | "shellPath":"/bin/bash", 48 | "shellArgs":["-l"] 49 | }, 50 | { 51 | "label": "Restricted Bash", 52 | "shellPath": "/bin/rbash" 53 | }, 54 | { 55 | "label":"sh", 56 | "shellPath":"/bin/sh" 57 | } 58 | ] 59 | ``` 60 | 61 | ## Contribution 62 | 63 | - Check for the issues on https://github.com/saurabhdaware/vscode-terminal-manager/issues 64 | - Fork the project 65 | - Finish your changes and make Pull Request to Master branch of https://github.com/saurabhdaware/vscode-terminal-manager 66 | 67 | ## Local Development 68 | 69 | - Fork this project 70 | - `git clone https://github.com/{your username}/vscode-terminal-manager` 71 | - `cd vscode-terminal-manager` 72 | - `npm install` 73 | - Open the project in Visual Studio Code and press `Ctrl + f5` to start Extension host. 74 | 75 | ## Release Notes 76 | 77 | ### 1.0.0 - 1.0.4 78 | 79 | - Initial Release of Terminal Manager and Minor Updates. 80 | 81 | ### 1.0.5 82 | 83 | - Fixed Path error that was thrown in Ubuntu when edit button was clicked 84 | 85 | ### 1.0.6 86 | 87 | - shellArgs can be added to terminal (Thanks to [#PR5](https://github.com/saurabhdaware/vscode-terminal-manager/pull/5) by [4a-42](https://github.com/4a-42)) 88 | - added default terminals.json configs for linux and osx 89 | 90 | 91 | ---- 92 | 93 | ***Dont forget to star my github repository https://github.com/saurabhdaware/vscode-terminal-manager*** 94 | 95 | ***Enjoy 🎉*** 96 | -------------------------------------------------------------------------------- /commands.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const vscode = require('vscode'); 3 | const path = require('path'); 4 | const process = require('process'); 5 | 6 | class TerminalTree{ 7 | constructor(terminals){ 8 | this.terminals = terminals; 9 | this.i = -1; 10 | } 11 | getChildren(element){ 12 | console.log(element); 13 | return this.terminals; 14 | } 15 | 16 | getTreeItem(element){ 17 | console.log(element); 18 | this.i++; 19 | let terminal = this.terminals[this.i]; 20 | return { 21 | label:terminal.label, 22 | tooltip:`Open ${terminal.label}`, 23 | command:{command:terminal.command,title:terminal.commandTitle} 24 | } 25 | } 26 | 27 | getParent(element){ 28 | console.log(element); 29 | return 'd'; 30 | } 31 | } 32 | 33 | 34 | class TerminalManager{ 35 | constructor(context){ 36 | this.context = context; 37 | this.terminalsConfig = ''; 38 | // Adjust configurations as per the OS 39 | if(process.platform == 'linux'){ 40 | this.terminalsConfig = `[ 41 | { 42 | "label":"Login bash", 43 | "shellPath":"/bin/bash", 44 | "shellArgs":["-l"] 45 | }, 46 | { 47 | "label":"sh", 48 | "shellPath":"/bin/sh" 49 | } 50 | ]` 51 | }else if(process.platform == 'win32'){ 52 | this.terminalsConfig = `[ 53 | { 54 | "label":"Windows Powershell", 55 | "shellPath":"C://Windows//System32//WindowsPowerShell//v1.0//powershell.exe" 56 | }, 57 | { 58 | "label":"CMD", 59 | "shellPath":"C://Windows//System32//cmd.exe", 60 | "shellArgs":["/K", "echo Heya!"] 61 | } 62 | ]` 63 | }else{ 64 | this.terminalsConfig = `[ 65 | { 66 | "label":"Bash", 67 | "shellPath":"/bin/bash" 68 | } 69 | ]` 70 | } 71 | } 72 | 73 | getTerminals(){ 74 | let terminals; 75 | console.log("Platform"); 76 | console.log(process.platform); 77 | try{ 78 | const fileContent = fs.readFileSync(this.context.globalStoragePath+'/terminals.json'); 79 | console.log(fileContent); 80 | terminals = JSON.parse(fileContent); 81 | terminals = terminals.map(terminal => { 82 | terminal.command = 'extension.'+terminal.label.toLowerCase().replace(/ /g,''); 83 | terminal.commandTitle = terminal.label; 84 | return terminal; 85 | }) 86 | }catch(e){ 87 | console.log(e); 88 | fs.promises.mkdir(this.context.globalStoragePath,{recursive:true}) 89 | .then(() => { 90 | return fs.promises.writeFile(this.context.globalStoragePath+'/terminals.json',this.terminalsConfig) 91 | }) 92 | .catch((e) => { 93 | console.log(e); 94 | }) 95 | 96 | terminals = []; 97 | } 98 | 99 | return terminals; 100 | } 101 | 102 | loadTerminals(){ 103 | let terminals = this.getTerminals(this.context); 104 | // vscode.workspace.onDidChangeTextDocument() 105 | let tree = vscode.window.createTreeView('terminal-manager', {treeDataProvider: new TerminalTree(terminals)}); 106 | 107 | this.context.subscriptions.push(tree); 108 | // vscode.window.showInformationMessage('Congratulations, your extension "terminal-manager" is now active!'); 109 | for(let terminal of terminals){ 110 | let cmd = vscode.commands.registerCommand(terminal.command, function () { 111 | let terminalInstance = vscode.window.createTerminal(terminal.commandTitle,terminal.shellPath,terminal.shellArgs); 112 | terminalInstance.show(); 113 | }); 114 | this.context.subscriptions.push(cmd); 115 | } 116 | 117 | return Promise.resolve(this.context.subscriptions) 118 | } 119 | 120 | loadCommands(){ 121 | let editTerminals = vscode.commands.registerCommand('extension.editTerminals',() => { 122 | let terminalsJsonPath = path.join(this.context.globalStoragePath,'terminals.json'); 123 | vscode.window.showTextDocument(vscode.Uri.file(terminalsJsonPath)) 124 | .catch(console.log); 125 | }) 126 | this.context.subscriptions.push(editTerminals); 127 | 128 | return Promise.resolve(this.context.subscriptions); 129 | } 130 | 131 | } 132 | 133 | module.exports = TerminalManager; --------------------------------------------------------------------------------