├── .vscodeignore ├── images ├── bash-128x128.png └── bash-128x128_white.png ├── vscode-shell-snippets-0.3.0.vsix ├── .dockerignore ├── Dockerfile ├── tslint.json ├── README.deepIT.md ├── TODO ├── LICENSE.md ├── src ├── test │ ├── suite │ │ ├── extension.test.ts │ │ └── index.ts │ └── runTest.ts └── extension.ts ├── out ├── test │ ├── runTest.js.map │ ├── suite │ │ ├── extension.test.js.map │ │ ├── extension.test.js │ │ ├── index.js.map │ │ └── index.js │ └── runTest.js ├── extension.js.map └── extension.js ├── tsconfig.json ├── CHANGELOG.md ├── .build └── postinstall.js ├── LICENSE.deepIT ├── LICENSE.MIT ├── snippets ├── bulk-snippets.json ├── shellscript.json └── tests.json ├── README.md ├── package.json ├── CODE_OF_CODUCT.md └── .gitignore /.vscodeignore: -------------------------------------------------------------------------------- 1 | **/*.ts 2 | **/tsconfig.json 3 | !file.ts -------------------------------------------------------------------------------- /images/bash-128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeepInThought/vscode-shell-snippets/HEAD/images/bash-128x128.png -------------------------------------------------------------------------------- /images/bash-128x128_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeepInThought/vscode-shell-snippets/HEAD/images/bash-128x128_white.png -------------------------------------------------------------------------------- /vscode-shell-snippets-0.3.0.vsix: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeepInThought/vscode-shell-snippets/HEAD/vscode-shell-snippets-0.3.0.vsix -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | Dockerfile* 4 | docker-compose* 5 | .dockerignore 6 | .git 7 | .gitignore 8 | .env 9 | */bin 10 | */obj 11 | README.md 12 | LICENSE 13 | .vscode -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:latest as ubuntu_builder 2 | RUN apt-get -y update && apt-get install curl -y 3 | 4 | ### FROM deepinthought/vscode-shell-snippets:latest 5 | COPY . /vscode-shell-snippets 6 | LABEL Name=vscode-shell-snippets Version=0.1.0 7 | CMD [ "/bin/bash", "cd /vscode-shell-snippets" ] -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-string-throw": true, 4 | "no-unused-expression": true, 5 | "no-duplicate-variable": true, 6 | "curly": true, 7 | "class-name": true, 8 | "semicolon": [ 9 | true, 10 | "always" 11 | ], 12 | "triple-equals": true 13 | }, 14 | "defaultSeverity": "warning" 15 | } -------------------------------------------------------------------------------- /README.deepIT.md: -------------------------------------------------------------------------------- 1 | # About DeepInThought 2 | 3 | By [@DeepInThought](https://github.com/DeepInThought). 4 | 5 | --- 6 | 7 | ## Contact DeepInThought 8 | 9 | [@DeepInThought](https://github.com/DeepInThought). 10 | 11 | * Official Website - [https://www.deepinthought.io](https://www.deepinthought.io) 12 | * Email - [support@deepinthought.io](mailto:support@deepinthought.io). 13 | * GitHub - [Github](https://github.com/DeepInThought) 14 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | # todo: 2 | [x] Add snippets: https://code.visualstudio.com/docs/editor/userdefinedsnippets 3 | [x] Publish to marketplace: https://marketplace.visualstudio.com/manage/publishers/deepinthought 4 | [x] Follow guildlines: https://code.visualstudio.com/docs/extensionAPI/extension-manifest 5 | [-] Add colors: https://misc.flogisoft.com/bash/tip_colors_and_formatting 6 | [-] Add flags: https://codeburst.io/13-tips-tricks-for-writing-shell-scripts-with-awesome-ux-19a525ae05ae 7 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # License information 2 | 3 | + Deep In Thought, LLC licensing information can be found here can be found in [LICENSE.deepIT](LICENSE.deepIT). 4 | 5 | + The snippets directory contains [snippets/frequently-used.json](snippets/frequently-used.json) and [snippets/shellscript.json](snippets/shellscript.json). 6 | 7 | + These were pulled originally from: [https://github.com/cdsama/shell-snippets](https://github.com/cdsama/shell-snippets) 8 | + Please see original license information at [LICENSE.MIT](LICENSE.MIT). 9 | -------------------------------------------------------------------------------- /src/test/suite/extension.test.ts: -------------------------------------------------------------------------------- 1 | import * as assert from 'assert'; 2 | 3 | // You can import and use all API from the 'vscode' module 4 | // as well as import your extension to test it 5 | import * as vscode from 'vscode'; 6 | // import * as myExtension from '../extension'; 7 | 8 | suite('Extension Test Suite', () => { 9 | vscode.window.showInformationMessage('Start all tests.'); 10 | 11 | test('Sample test', () => { 12 | assert.equal(-1, [1, 2, 3].indexOf(5)); 13 | assert.equal(-1, [1, 2, 3].indexOf(0)); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /out/test/runTest.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"runTest.js","sourceRoot":"","sources":["../../src/test/runTest.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,6BAA6B;AAE7B,6CAAuC;AAEvC,SAAe,IAAI;;QAClB,IAAI;YACH,4DAA4D;YAC5D,yCAAyC;YACzC,MAAM,wBAAwB,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YAEnE,0BAA0B;YAC1B,iCAAiC;YACjC,MAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;YAEpE,0DAA0D;YAC1D,MAAM,sBAAQ,CAAC,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,CAAC,CAAC;SACjE;QAAC,OAAO,GAAG,EAAE;YACb,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;YACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SAChB;IACF,CAAC;CAAA;AAED,IAAI,EAAE,CAAC"} -------------------------------------------------------------------------------- /out/extension.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;AAAA,6DAA6D;AAC7D,8EAA8E;AAC9E,iCAAiC;AAEjC,yDAAyD;AACzD,0EAA0E;AAC1E,SAAgB,QAAQ,CAAC,OAAgC;IACxD,4FAA4F;IAC5F,gFAAgF;IAChF,OAAO,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;IAEnE,wDAAwD;IACxD,qEAAqE;IACrE,uEAAuE;IACvE,IAAI,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACtF,+EAA+E;QAE/E,oCAAoC;QACpC,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,+EAA+E,CAAC,CAAC;IACvH,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACxC,CAAC;AAhBD,4BAgBC;AAED,2DAA2D;AAC3D,SAAgB,UAAU,KAAI,CAAC;AAA/B,gCAA+B"} -------------------------------------------------------------------------------- /out/test/suite/extension.test.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"extension.test.js","sourceRoot":"","sources":["../../../src/test/suite/extension.test.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAEjC,0DAA0D;AAC1D,8CAA8C;AAC9C,iCAAiC;AACjC,+CAA+C;AAE/C,KAAK,CAAC,sBAAsB,EAAE,GAAG,EAAE;IAClC,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,kBAAkB,CAAC,CAAC;IAEzD,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE;QACxB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /out/test/suite/extension.test.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const assert = require("assert"); 4 | // You can import and use all API from the 'vscode' module 5 | // as well as import your extension to test it 6 | const vscode = require("vscode"); 7 | // import * as myExtension from '../extension'; 8 | suite('Extension Test Suite', () => { 9 | vscode.window.showInformationMessage('Start all tests.'); 10 | test('Sample test', () => { 11 | assert.equal(-1, [1, 2, 3].indexOf(5)); 12 | assert.equal(-1, [1, 2, 3].indexOf(0)); 13 | }); 14 | }); 15 | //# sourceMappingURL=extension.test.js.map -------------------------------------------------------------------------------- /src/test/runTest.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | 3 | import { runTests } from 'vscode-test'; 4 | 5 | async function main() { 6 | try { 7 | // The folder containing the Extension Manifest package.json 8 | // Passed to `--extensionDevelopmentPath` 9 | const extensionDevelopmentPath = path.resolve(__dirname, '../../'); 10 | 11 | // The path to test runner 12 | // Passed to --extensionTestsPath 13 | const extensionTestsPath = path.resolve(__dirname, './suite/index'); 14 | 15 | // Download VS Code, unzip it and run the integration test 16 | await runTests({ extensionDevelopmentPath, extensionTestsPath }); 17 | } catch (err) { 18 | console.error('Failed to run tests'); 19 | process.exit(1); 20 | } 21 | } 22 | 23 | main(); 24 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es6", 5 | "outDir": "out", 6 | "lib": [ 7 | "es6" 8 | ], 9 | "sourceMap": true, 10 | "rootDir": "src", 11 | "strict": true /* enable all strict type-checking options */ 12 | /* Additional Checks */ 13 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 14 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 15 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 16 | }, 17 | "exclude": [ 18 | "node_modules", 19 | ".vscode-test" 20 | ] 21 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Visual Studio Code Shell Snippets Changelog 2 | 3 | [CHANGELOG.md](https://raw.githubusercontent.com/DeepInThought/vscode-shell-snippets/master/CHANGELOG.md). 4 | 5 | ## Version 0.3.0 6 | 7 | - Fixed bug where extension would always be disabled. 8 | - Changed snippets to new JSON files to match usage. 9 | - Added extension TypeScript file for future usage. 10 | - Removed useless dependencies in the package.json file. 11 | - Improved all of the entries in the snippets files. 12 | They now pass shellcheck and work as intended. 13 | - Improved description and choices for entries. 14 | 15 | ## Version 0.2.0 16 | 17 | - [Vulnerabilies] Security vulnerabilities detected in dependencies. 18 | - Dependency event-stream associated with [flatmap-stream](https://github.com/dominictarr/event-stream/issues/116) was found malicious. 19 | -------------------------------------------------------------------------------- /src/test/suite/index.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | import * as Mocha from 'mocha'; 3 | import * as glob from 'glob'; 4 | 5 | export function run(): Promise { 6 | // Create the mocha test 7 | const mocha = new Mocha({ 8 | ui: 'tdd', 9 | }); 10 | mocha.useColors(true); 11 | 12 | const testsRoot = path.resolve(__dirname, '..'); 13 | 14 | return new Promise((c, e) => { 15 | glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { 16 | if (err) { 17 | return e(err); 18 | } 19 | 20 | // Add files to the test suite 21 | files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); 22 | 23 | try { 24 | // Run the mocha test 25 | mocha.run(failures => { 26 | if (failures > 0) { 27 | e(new Error(`${failures} tests failed.`)); 28 | } else { 29 | c(); 30 | } 31 | }); 32 | } catch (err) { 33 | e(err); 34 | } 35 | }); 36 | }); 37 | } 38 | -------------------------------------------------------------------------------- /.build/postinstall.js: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See License.txt in the project root for license information. 4 | *--------------------------------------------------------------------------------------------*/ 5 | 6 | const fs = require('fs'); 7 | const path = require('path'); 8 | const cp = require('child_process'); 9 | const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm'; 10 | 11 | function npmInstall(location) { 12 | const result = cp.spawnSync(npm, ['install'], { 13 | cwd: location, 14 | stdio: 'inherit' 15 | }); 16 | 17 | if (result.error || result.status !== 0) { 18 | process.exit(1); 19 | } 20 | } 21 | 22 | 23 | const cwd = process.cwd(); 24 | for (const element of fs.readdirSync(cwd)) { 25 | const fullpath = path.join(cwd, element, 'package.json'); 26 | if (fs.existsSync(fullpath)) { 27 | npmInstall(path.join(cwd, element)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /out/test/suite/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/test/suite/index.ts"],"names":[],"mappings":";;AAAA,6BAA6B;AAC7B,+BAA+B;AAC/B,6BAA6B;AAE7B,SAAgB,GAAG;IAClB,wBAAwB;IACxB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC;QACvB,EAAE,EAAE,KAAK;KACT,CAAC,CAAC;IACH,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAEtB,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAEhD,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC3B,IAAI,CAAC,eAAe,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YACxD,IAAI,GAAG,EAAE;gBACR,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;aACd;YAED,8BAA8B;YAC9B,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAE9D,IAAI;gBACH,qBAAqB;gBACrB,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;oBACpB,IAAI,QAAQ,GAAG,CAAC,EAAE;wBACjB,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,QAAQ,gBAAgB,CAAC,CAAC,CAAC;qBAC1C;yBAAM;wBACN,CAAC,EAAE,CAAC;qBACJ;gBACF,CAAC,CAAC,CAAC;aACH;YAAC,OAAO,GAAG,EAAE;gBACb,CAAC,CAAC,GAAG,CAAC,CAAC;aACP;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC;AAhCD,kBAgCC"} -------------------------------------------------------------------------------- /LICENSE.deepIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Deep In Thought, LLC 2 | 3 | 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: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | 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. -------------------------------------------------------------------------------- /LICENSE.MIT: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 chendi 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 | -------------------------------------------------------------------------------- /out/test/suite/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const path = require("path"); 4 | const Mocha = require("mocha"); 5 | const glob = require("glob"); 6 | function run() { 7 | // Create the mocha test 8 | const mocha = new Mocha({ 9 | ui: 'tdd', 10 | }); 11 | mocha.useColors(true); 12 | const testsRoot = path.resolve(__dirname, '..'); 13 | return new Promise((c, e) => { 14 | glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { 15 | if (err) { 16 | return e(err); 17 | } 18 | // Add files to the test suite 19 | files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); 20 | try { 21 | // Run the mocha test 22 | mocha.run(failures => { 23 | if (failures > 0) { 24 | e(new Error(`${failures} tests failed.`)); 25 | } 26 | else { 27 | c(); 28 | } 29 | }); 30 | } 31 | catch (err) { 32 | e(err); 33 | } 34 | }); 35 | }); 36 | } 37 | exports.run = run; 38 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /snippets/bulk-snippets.json: -------------------------------------------------------------------------------- 1 | { 2 | "file_read_by_line":{ 3 | "prefix": "file_read_by_line", 4 | "body": "{\nwhile IFS= read -r \"lineNum\"\ndo\n\techo \"\\${lineNum}\"\ndone\n} < \"${0:FILE_NAME}\"", 5 | "description": "Read a text file line by line." 6 | }, 7 | "file_batch_rename":{ 8 | "prefix": "file_batch_rename", 9 | "body": "ls | xargs -i mv {} {}.${1:old}", 10 | "description": "Rename all files in a directory." 11 | }, 12 | "awk_substr":{ 13 | "prefix": "awk_substr", 14 | "body": "echo \"${1:VAR_OR_STRING}\" | awk '{print substr(\\$0,0,length(\\$0)-${2|AMOUNT_TO_CUT_BY,1,2,3|}'", 15 | "description": "A sub string with awk. Change AMOUNT_TO_CUT_BY to a valid integer." 16 | }, 17 | "awk_printf":{ 18 | "prefix": "awk_printf", 19 | "body": "awk -F ':' '{printf(\"filename:%10s,linenumber:%s,columns:%s,linecontent:%s\\n\",FILENAME,NR,NF,\\$0)\\}' /etc/passwd", 20 | "description": "A printf example inside of awk." 21 | }, 22 | "awk_for_loop":{ 23 | "prefix": "awk_for_loop", 24 | "body": "awk -F ':' 'BEGIN {count=0;} {name[count] = \\$1;count++;\\}; END{for (i = 0; i < NR; i++) print i, name[i]\\}' /etc/passwd", 25 | "description": "A loop example in awk to show all users in /etc/passwd" 26 | } 27 | } -------------------------------------------------------------------------------- /src/extension.ts: -------------------------------------------------------------------------------- 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 | import * as vscode from 'vscode'; 4 | 5 | // this method is called when your extension is activated 6 | // your extension is activated the very first time the command is executed 7 | export function activate(context: vscode.ExtensionContext) { 8 | // Use the console to output diagnostic information (console.log) and errors (console.error) 9 | // This line of code will only be executed once when your extension is activated 10 | console.log('VSCode Shell Snippets has been loaded successfully!'); 11 | 12 | // The command has been defined in the package.json file 13 | // Now provide the implementation of the command with registerCommand 14 | // The commandId parameter must match the command field in package.json 15 | let disposable = vscode.commands.registerCommand('extension.vscodeShellSnippets', () => { 16 | // The code you place here will be executed every time your command is executed 17 | 18 | // Display a message box to the user 19 | vscode.window.showInformationMessage('Shell Snippets for VSCode will be picked up in language: "shellscript" files.'); 20 | }); 21 | 22 | context.subscriptions.push(disposable); 23 | } 24 | 25 | // this method is called when your extension is deactivated 26 | export function deactivate() {} -------------------------------------------------------------------------------- /out/extension.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | // The module 'vscode' contains the VS Code extensibility API 4 | // Import the module and reference it with the alias vscode in your code below 5 | const vscode = require("vscode"); 6 | // this method is called when your extension is activated 7 | // your extension is activated the very first time the command is executed 8 | function activate(context) { 9 | // Use the console to output diagnostic information (console.log) and errors (console.error) 10 | // This line of code will only be executed once when your extension is activated 11 | console.log('VSCode Shell Snippets has been loaded successfully!'); 12 | // The command has been defined in the package.json file 13 | // Now provide the implementation of the command with registerCommand 14 | // The commandId parameter must match the command field in package.json 15 | let disposable = vscode.commands.registerCommand('extension.vscodeShellSnippets', () => { 16 | // The code you place here will be executed every time your command is executed 17 | // Display a message box to the user 18 | vscode.window.showInformationMessage('Shell Snippets for VSCode will be picked up in language: "shellscript" files.'); 19 | }); 20 | context.subscriptions.push(disposable); 21 | } 22 | exports.activate = activate; 23 | // this method is called when your extension is deactivated 24 | function deactivate() { } 25 | exports.deactivate = deactivate; 26 | //# sourceMappingURL=extension.js.map -------------------------------------------------------------------------------- /out/test/runTest.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | const path = require("path"); 13 | const vscode_test_1 = require("vscode-test"); 14 | function main() { 15 | return __awaiter(this, void 0, void 0, function* () { 16 | try { 17 | // The folder containing the Extension Manifest package.json 18 | // Passed to `--extensionDevelopmentPath` 19 | const extensionDevelopmentPath = path.resolve(__dirname, '../../'); 20 | // The path to test runner 21 | // Passed to --extensionTestsPath 22 | const extensionTestsPath = path.resolve(__dirname, './suite/index'); 23 | // Download VS Code, unzip it and run the integration test 24 | yield vscode_test_1.runTests({ extensionDevelopmentPath, extensionTestsPath }); 25 | } 26 | catch (err) { 27 | console.error('Failed to run tests'); 28 | process.exit(1); 29 | } 30 | }); 31 | } 32 | main(); 33 | //# sourceMappingURL=runTest.js.map -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Visual Studio Code Shell Snippets 2 | 3 | Code snippets of bash shell commands, functions and scripts for visual studio code. 4 | 5 | 6 | [Visual Studio Code Shell Snippets](#visual-studio-code-shell-snippets) 7 | 8 | 1. [Installation](#installation) 9 | 2. [Source Code](#source-code) 10 | 3. [Snippets](#snippets) 11 | 1. [Common](#common) 12 | 2. [Tests](#tests) 13 | 3. [Bulk](#bulk) 14 | 4. [About Us](#about-us) 15 | 1. [Licensing Information](#licensing-information) 16 | 17 | 18 | 19 | ## Installation 20 | 21 | Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter. 22 | 23 | ```typescript 24 | ext install vscode-shell-snippets 25 | ``` 26 | 27 | ## Source Code 28 | 29 | Repository Home: [https://github.com/DeepInThought/vscode-shell-snippets.git](https://github.com/DeepInThought/vscode-shell-snippets.git) 30 | 31 | ## Snippets 32 | 33 | ### Common 34 | 35 | JSON File: [snippets/shellscript.json](snippets/shellscript.json) 36 | 37 | * if/elif/else 38 | * echo/read 39 | * for/while/until/break 40 | * function 41 | * case expr 42 | 43 | ### Tests 44 | 45 | JSON File: [snippets/tests.json](snippets/tests.json) 46 | 47 | * test int/string/file 48 | 49 | ### Bulk 50 | 51 | JSON File: [snippets/bulk-snippets.json](snippets/bulk-snippets.json) 52 | 53 | * read file by line 54 | * batch rename files 55 | * awk 56 | * substr 57 | * printf 58 | * for loop 59 | 60 | ## About Us 61 | 62 | Visit [README.deepIT.md](README.deepIT.md) for more information on [@DeepInThought]((https://github.com/DeepInThought)). 63 | 64 | 65 | 66 | 67 | ### Licensing Information 68 | 69 | * Please visit: [LICENSE.md](LICENSE.md). 70 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vscode-shell-snippets", 3 | "displayName": "Visual Studio Code Shell Snippets", 4 | "description": "This extension adds Bash shell script snippets for fast scripting.", 5 | "version": "0.3.0", 6 | "publisher": "DeepInThought", 7 | "icon": "images/bash-128x128.png", 8 | "galleryBanner": { 9 | "color": "#C80000", 10 | "theme": "dark" 11 | }, 12 | "author": { 13 | "name": "DeepInThought", 14 | "email": "support@deepinthought.io", 15 | "url": "https://www.deepinthought.io" 16 | }, 17 | "license": "SEE LICENSE.md", 18 | "engines": { 19 | "vscode": "^1.30.0", 20 | "node": ">=4.2.0" 21 | }, 22 | "categories": [ 23 | "Snippets", 24 | "Keymaps" 25 | ], 26 | "contributes": { 27 | "snippets": [ 28 | { 29 | "language": "shellscript", 30 | "path": "./snippets/shellscript.json" 31 | }, 32 | { 33 | "language": "shellscript", 34 | "path": "./snippets/bulk-snippets.json" 35 | }, 36 | { 37 | "language": "shellscript", 38 | "path": "./snippets/tests.json" 39 | } 40 | ], 41 | "commands": [ 42 | { 43 | "command": "extension.vscodeShellSnippets", 44 | "title": "ShellSnippets: Info" 45 | } 46 | ] 47 | }, 48 | "repository": { 49 | "type": "git", 50 | "url": "https://github.com/DeepInThought/vscode-shell-snippets.git" 51 | }, 52 | "bugs": { 53 | "email": "support@deepinthought.io", 54 | "url": "https://github.com/DeepInThought/vscode-shell-snippets/issues" 55 | }, 56 | "homepage": "https://github.com/DeepInThought/vscode-shell-snippets/blob/master/README.md", 57 | "config": { 58 | "configFileName": "tsconfig.json" 59 | }, 60 | "activationEvents": [ 61 | "onCommand:extension.vscodeShellSnippets" 62 | ], 63 | "main": "./out/extension.js", 64 | "typings": "./out/extension.d.ts", 65 | "bin": { 66 | "tsc": "./bin/tsc", 67 | "tsserver": "./bin/tsserver" 68 | }, 69 | "scripts": { 70 | "vscode:prepublish": "npm run compile", 71 | "compile": "tsc -p ./", 72 | "watch": "tsc -watch -p ./", 73 | "pretest": "npm run compile", 74 | "test": "node ./out/test/runTest.js" 75 | }, 76 | "devDependencies": { 77 | "@types/glob": "^7.1.1", 78 | "@types/mocha": "^5.2.7", 79 | "@types/node": "^13.1.1", 80 | "@types/vscode": "^1.30.0", 81 | "glob": "^7.1.6", 82 | "mocha": "^6.2.2", 83 | "typescript": "^3.7.4", 84 | "tslint": "^5.20.1", 85 | "vscode-test": "^1.3.0" 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /CODE_OF_CODUCT.md: -------------------------------------------------------------------------------- 1 | # Deep Contributor Covenant Code of Conduct 2 | 3 | ## Deep Pledge 4 | 5 | [@DeepInThought](https://github.com/DeepInThought) doesn't discreminate. 6 | 7 | We understand that everyone has a different take on life, religion and level of experience. 8 | 9 | Always [DeepInThought](https://www.deepinthought.io) and viewing technology from a different angle. 10 | 11 | ## Deep Standards 12 | 13 | Examples of behavior that contributes to creating a positive environment include: 14 | 15 | * Open minded contributors 16 | * Indifferent to the norm 17 | * Sarcasim where needed 18 | * Accepting constructive criticism 19 | * Focusing on what is best for the community 20 | 21 | Examples of unacceptable behavior by participants include: 22 | 23 | * Pornagraphic material in an open settings is taboo 24 | * Auto-botting Social Media 25 | * Excessive trolling 26 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 27 | 28 | ## Deep Responsibilites 29 | 30 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 31 | 32 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 33 | 34 | ## Scope 35 | 36 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 37 | 38 | ## Enforcement 39 | 40 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at support@deepinthought.io. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 41 | 42 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 43 | 44 | ## Attribution 45 | 46 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 47 | 48 | [homepage]: http://contributor-covenant.org 49 | [version]: http://contributor-covenant.org/version/1/4/ -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://github.com/github/gitignore/blob/master/Global/VisualStudioCode.gitignore 2 | .vscode/* 3 | !.vscode/settings.json 4 | !.vscode/tasks.json 5 | !.vscode/launch.json 6 | !.vscode/extensions.json 7 | 8 | # See https://github.com/github/gitignore/blob/master/Global/Backup.gitignore 9 | *.bak 10 | *.gho 11 | *.ori 12 | *.orig 13 | *.tmp 14 | 15 | # https://github.com/Microsoft/vscode-extension-samples/blob/master/.gitignore 16 | .DS_Store 17 | npm-debug.log 18 | Thumbs.db 19 | */node_modules/ 20 | */out/ 21 | 22 | # TypeScript https://github.com/Microsoft/TypeScript/blob/master/.gitignore 23 | node_modules/ 24 | .node_modules/ 25 | built/* 26 | tests/cases/rwc/* 27 | tests/cases/test262/* 28 | tests/cases/perf/* 29 | !tests/cases/webharness/compilerToString.js 30 | test-args.txt 31 | ~*.docx 32 | \#*\# 33 | .\#* 34 | tests/baselines/local/* 35 | tests/baselines/local.old/* 36 | tests/services/baselines/local/* 37 | tests/baselines/prototyping/local/* 38 | tests/baselines/rwc/* 39 | tests/baselines/test262/* 40 | tests/baselines/reference/projectOutput/* 41 | tests/baselines/local/projectOutput/* 42 | tests/baselines/reference/testresults.tap 43 | tests/services/baselines/prototyping/local/* 44 | tests/services/browser/typescriptServices.js 45 | src/harness/*.js 46 | src/compiler/diagnosticInformationMap.generated.ts 47 | src/compiler/diagnosticMessages.generated.json 48 | src/parser/diagnosticInformationMap.generated.ts 49 | src/parser/diagnosticMessages.generated.json 50 | rwc-report.html 51 | *.swp 52 | build.json 53 | *.actual 54 | tests/webTestServer.js 55 | tests/webTestServer.js.map 56 | tests/webhost/*.d.ts 57 | tests/webhost/webtsc.js 58 | tests/cases/**/*.js 59 | tests/cases/**/*.js.map 60 | *.config 61 | scripts/debug.bat 62 | scripts/run.bat 63 | scripts/word2md.js 64 | scripts/buildProtocol.js 65 | scripts/ior.js 66 | scripts/authors.js 67 | scripts/configurePrerelease.js 68 | scripts/open-user-pr.js 69 | scripts/processDiagnosticMessages.d.ts 70 | scripts/processDiagnosticMessages.js 71 | scripts/produceLKG.js 72 | scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js 73 | scripts/generateLocalizedDiagnosticMessages.js 74 | scripts/*.js.map 75 | scripts/typings/ 76 | coverage/ 77 | internal/ 78 | **/.DS_Store 79 | .settings 80 | **/.vs 81 | **/.vscode 82 | !**/.vscode/tasks.json 83 | !tests/cases/projects/projectOption/**/node_modules 84 | !tests/cases/projects/NodeModulesSearch/**/* 85 | !tests/baselines/reference/project/nodeModules*/**/* 86 | .idea 87 | yarn.lock 88 | yarn-error.log 89 | .parallelperf.* 90 | tests/cases/user/*/package-lock.json 91 | tests/cases/user/*/node_modules/ 92 | tests/cases/user/*/**/*.js 93 | tests/cases/user/*/**/*.js.map 94 | tests/cases/user/*/**/*.d.ts 95 | !tests/cases/user/zone.js/ 96 | !tests/cases/user/bignumber.js/ 97 | !tests/cases/user/discord.js/ 98 | tests/baselines/reference/dt 99 | .failed-tests 100 | TEST-results.xml 101 | package-lock.json -------------------------------------------------------------------------------- /snippets/shellscript.json: -------------------------------------------------------------------------------- 1 | { 2 | "bash": { 3 | "prefix": [ 4 | "bash", 5 | "#!", 6 | "shebang" 7 | ], 8 | "body": "${1|#!/bin/bash,#!/usr/bin/env bash|}\n", 9 | "description": [ 10 | "Option 1:\n", 11 | "#!/bin/bash\n", 12 | "Description: Shebang Bash executor.\n", 13 | "Option 2:\n", 14 | "#!/usr/bin/env bash\n", 15 | "Description: Shell searchs for the first match of bash in the $PATH environment variable.\n", 16 | "It can be useful if you aren't aware of the absolute path or don't want to search for it.\n" 17 | ] 18 | }, 19 | "echo": { 20 | "prefix": "echo", 21 | "body": "echo \"${0:message}\"", 22 | "description": "Echo a message." 23 | }, 24 | "read": { 25 | "prefix": "read", 26 | "body": "read -r ${0:VAR}", 27 | "description": "Read input of ${VAR}." 28 | }, 29 | "if": { 30 | "prefix": "if", 31 | "body": "if [[ ${0:condition} ]]; then\n\t${1}\nfi", 32 | "description": "An IF statement." 33 | }, 34 | "elseif": { 35 | "prefix": "elseif", 36 | "body": "elif [[ ${0:condition} ]]; then\n\t${1}", 37 | "description": "Add an elseif to an if statement." 38 | }, 39 | "else": { 40 | "prefix": "else", 41 | "body": "else\n\t${0:command}", 42 | "description": "else" 43 | }, 44 | "for_in": { 45 | "prefix": "for_in", 46 | "body": "for ${0:VAR} in $${1:LIST}\ndo\n\techo \"$${0:VAR}\"\ndone\n", 47 | "description": "for loop in list" 48 | }, 49 | "for_i": { 50 | "prefix": "for_i", 51 | "body": "for ((${0:i} = 0; ${0:i} < ${1:10}; ${0:i}++)); do\n\techo \"$${0:i}\"\ndone\n", 52 | "description": "An index-based iteration for loop." 53 | }, 54 | "while": { 55 | "prefix": "while", 56 | "body": "while [[ ${1:condition} ]]; do\n\t${0}\ndone\n", 57 | "description": "A while loop by condition." 58 | }, 59 | "until": { 60 | "prefix": "until", 61 | "body": "until [[ ${1:condition} ]]; do\n\t${0}\ndone\n", 62 | "description": "until loop by condition" 63 | }, 64 | "function": { 65 | "prefix": "function", 66 | "body": "${1:name} ()\n{\n\t${0}\n}", 67 | "description": [ 68 | "This defines a function named name.\n", 69 | "The reserved word function is optional.\n", 70 | "If the function reserved word is supplied, the parentheses are optional.\n", 71 | "1. Recommended way:\n", 72 | "name() {}\n", 73 | "2. C-like-way:\nfunction name [()] {}" 74 | ] 75 | }, 76 | "case": { 77 | "prefix": "case", 78 | "body": "case \"$${0:VAR}\" in\n\t${1:1}) echo 1\n\t;;\n\t${2:2|3}) echo 2 or 3\n\t;;\n\t*) echo default\n\t;;\nesac\n", 79 | "description": [ 80 | "case word in [ [(] pattern [ | pattern ] ... ) list ;; ] ... esac\n", 81 | "A case command first expands word, and tries to match it against each pattern in turn." 82 | ] 83 | }, 84 | "break": { 85 | "prefix": "break", 86 | "body": "break ${0}", 87 | "description": [ 88 | "The break command tells Bash to leave the loop straight away.\n", 89 | "Enter the break or break (n) where n=number of loops." 90 | ] 91 | }, 92 | "expr": { 93 | "prefix": "expr", 94 | "body": "expr ${0:1 + 1}", 95 | "description": "Calculate numbers with Bash." 96 | } 97 | } -------------------------------------------------------------------------------- /snippets/tests.json: -------------------------------------------------------------------------------- 1 | { 2 | "test_string_empty": { 3 | "prefix": "test_string_empty", 4 | "body": "test -z \"$${0:VAR}\"", 5 | "description": "A test to check the lengh of VAR is zero (i.e. it is empty) and returns TRUE if so." 6 | }, 7 | "test_string_equal": { 8 | "prefix": "test_string_equal", 9 | "body": "test \"$${0:VAR1}\" = \"$${1:VAR2}\"", 10 | "description": "A test to compare two different STRINGS and returns TRUE if they are of equal value." 11 | }, 12 | "test_string_not_empty": { 13 | "prefix": "test_string_not_empty", 14 | "body": "test -n \"$${0:VAR}\"", 15 | "description": "A test that checks the length of a STRING is greater than zero and returns TRUE if so." 16 | }, 17 | "test_string_not_equal": { 18 | "prefix": "test_string_not_equal", 19 | "body": "test \"$${0:VAR1}\" != \"$${1:VAR2}\"", 20 | "description": "A test to compare two different STRINGS. Returns TRUE if they are NOT of equal value." 21 | }, 22 | "test_int_equal": { 23 | "prefix": "test_int_equal", 24 | "body": "test \"$${0:VAR1}\" -eq \"$${1:VAR2}\"", 25 | "description": "A test to compare two different INTEGERS. Returns TRUE if they are of equal value." 26 | }, 27 | "test_int_great_equal": { 28 | "prefix": "test_int_great_equal", 29 | "body": "test \"$${0:VAR1}\" -ge \"$${1:VAR2}\"", 30 | "description": "A test to compare two different INTEGERS. Returns TRUE if INTEGER1 is of equal or greater value than INTEGER2." 31 | }, 32 | "test_int_great_than": { 33 | "prefix": "test_int_great_than", 34 | "body": "test \"$${0:VAR1}\" -gt \"$${1:VAR2}\"", 35 | "description": "A test to compare two different INTEGERS. Returns TRUE if INTEGER1 is greater than INTEGER2 in value." 36 | }, 37 | "test_int_less_equal": { 38 | "prefix": "test_int_less_equal", 39 | "body": "test \"$${0:VAR1}\" -le \"$${1:VAR2}\"", 40 | "description": "A test to compare two different INTEGERS. Returns TRUE if INTEGER1 is less than or equal to INTEGER2 in value." 41 | }, 42 | "test_int_less_than": { 43 | "prefix": "test_int_less_than", 44 | "body": "test \"$${0:VAR1}\" -lt \"$${1:VAR2}\"", 45 | "description": "A test to compare two different INTEGERS. Returns TRUE if INTEGER1 is less than INTEGER2 in value." 46 | }, 47 | "test_int_not_equal": { 48 | "prefix": "test_int_not_equal", 49 | "body": "test \"$${0:VAR1}\" -ne \"$${1:VAR2}", 50 | "description": "A test to compare two different INTEGERS. Returns TRUE if INTEGER1 is NOT equal to INTEGER2 in value." 51 | }, 52 | "test_exist": { 53 | "prefix": "test_exist_file", 54 | "body": "test -e \"$${0:VAR}\"", 55 | "description": "A test to check if FILE exists." 56 | }, 57 | "test_exist_file": { 58 | "prefix": "test_exist_regular_file", 59 | "body": "test -f \"$${0:VAR}\"", 60 | "description": "A test to check if FILE exists and is a regular file." 61 | }, 62 | "test_exist_directory": { 63 | "prefix": "test_exist_directory", 64 | "body": "test -d \"$${0:VAR}\"", 65 | "description": "A test to check if a FILE exists and is a directory." 66 | }, 67 | "test_exist_readable": { 68 | "prefix": "test_exist_readable", 69 | "body": "test -r \"$${0:VAR}\"", 70 | "description": "A test to check if FILE exists and read permission is granted." 71 | }, 72 | "test_exist_writeable": { 73 | "prefix": "test_exist_writeable", 74 | "body": "test -w \"$${0:VAR}\"", 75 | "description": "A test to check if FILE exists and write permission is granted." 76 | }, 77 | "test_exist_executable": { 78 | "prefix": "test_exist_executable", 79 | "body": "test -x \"$${0:VAR}\"", 80 | "description": "A test to check if FILE exists and execute (or search) permission is granted." 81 | }, 82 | "test_exist_link": { 83 | "prefix": "test_exist_link", 84 | "body": "test -h \"$${0:VAR}\"", 85 | "description": "A test to check if FILE exists and is a symbolic link (same as -L)." 86 | }, 87 | "test_file_equal": { 88 | "prefix": "test_file_equal", 89 | "body": "test \"$${0:VAR}\" -ef \"$${1:VAR}\"", 90 | "description": "A test to check if FILE1 and FILE2 have the same device and inode numbers." 91 | }, 92 | "test_file_new_than": { 93 | "prefix": "test_file_new_than", 94 | "body": "test \"$${0:VAR}\" -nt \"$${1:VAR}\"", 95 | "description": "A test to check if FILE1 is newer (modification date) than FILE2." 96 | }, 97 | "test_file_old_than": { 98 | "prefix": "test_file_old_than", 99 | "body": "test \"$${0:VAR}\" -ot \"$${1:VAR}\"", 100 | "description": "A test to check if FILE1 is older than FILE2." 101 | } 102 | } --------------------------------------------------------------------------------