├── .gitignore ├── typings ├── node.d.ts └── vscode-typings.d.ts ├── .vscodeignore ├── .vscode ├── settings.json └── launch.json ├── jsconfig.json ├── README.md ├── test ├── extension.test.js └── index.js ├── extension.js ├── LICENSE.md └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ -------------------------------------------------------------------------------- /typings/node.d.ts: -------------------------------------------------------------------------------- 1 | /// -------------------------------------------------------------------------------- /typings/vscode-typings.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | typings/** 3 | test/** 4 | .gitignore 5 | jsconfig.json 6 | vsc-extension-quickstart.md 7 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "editor.tabSize": 4, 4 | "editor.insertSpaces": false, 5 | "files.trimTrailingWhitespace": true 6 | } -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "ES5", 5 | "noLib": true 6 | }, 7 | "exclude": [ 8 | "node_modules" 9 | ] 10 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Copy Relative Path 2 | 3 | ![copy-relative-path](https://cloud.githubusercontent.com/assets/5047891/18313606/d284b04a-750f-11e6-9d0a-8c4f6a3a562e.gif) 4 | 5 | ![copy-relative-path-editor-tab](https://user-images.githubusercontent.com/1461792/32966849-c6d47e68-cba0-11e7-8451-f46dfba525fe.gif) 6 | 7 | **Enjoy!** -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension inside a new window 2 | { 3 | "version": "0.1.0", 4 | "configurations": [ 5 | { 6 | "name": "Launch Extension", 7 | "type": "extensionHost", 8 | "request": "launch", 9 | "runtimeExecutable": "${execPath}", 10 | "args": ["--extensionDevelopmentPath=${workspaceRoot}" ], 11 | "stopOnEntry": false 12 | }, 13 | { 14 | "name": "Launch Tests", 15 | "type": "extensionHost", 16 | "request": "launch", 17 | "runtimeExecutable": "${execPath}", 18 | "args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/test" ], 19 | "stopOnEntry": false 20 | } 21 | ] 22 | } -------------------------------------------------------------------------------- /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 | var 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 | var vscode = require('vscode'); 14 | var 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 | }); -------------------------------------------------------------------------------- /extension.js: -------------------------------------------------------------------------------- 1 | var vscode = require('vscode'); 2 | var copy = require('copy-paste').copy; 3 | 4 | function activate(context) { 5 | var disposable = vscode.commands.registerCommand('copyRelativePath', function (uri) { 6 | if (typeof uri === 'undefined') { 7 | if (vscode.window.activeTextEditor) { 8 | uri = vscode.window.activeTextEditor.document.uri; 9 | } 10 | } 11 | if (!uri) { 12 | vscode.window.showErrorMessage('Cannot copy relative path, as there appears no file is opened (or it is very large'); 13 | return; 14 | } 15 | var path = vscode.workspace.asRelativePath(uri); 16 | path = path.replace(/\\/g, '/'); 17 | copy(path); 18 | }); 19 | context.subscriptions.push(disposable); 20 | } 21 | exports.activate = activate; 22 | 23 | 24 | function deactivate() { 25 | } 26 | exports.deactivate = deactivate; -------------------------------------------------------------------------------- /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(testRoot: string, clb: (error:Error) => void) that the extension 9 | // 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 | var testRunner = require('vscode/lib/testrunner'); 14 | 15 | // You can directly control Mocha options by uncommenting the following lines 16 | // See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info 17 | testRunner.configure({ 18 | ui: 'tdd', // the TDD UI is being used in extension.test.js (suite, test, etc.) 19 | useColors: true // colored output from test results 20 | }); 21 | 22 | module.exports = testRunner; -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 Alexandru Dima 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 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "copy-relative-path", 3 | "displayName": "Copy Relative Path", 4 | "description": "Copy Relative Path from a File", 5 | "version": "0.0.2", 6 | "publisher": "alexdima", 7 | "engines": { 8 | "vscode": "^1.4.0" 9 | }, 10 | "categories": [ 11 | "Other" 12 | ], 13 | "activationEvents": [ 14 | "onCommand:copyRelativePath" 15 | ], 16 | "main": "./extension", 17 | "contributes": { 18 | "commands": [ 19 | { 20 | "command": "copyRelativePath", 21 | "title": "Copy Relative Path" 22 | } 23 | ], 24 | "menus": { 25 | "explorer/context": [ 26 | { 27 | "command": "copyRelativePath" 28 | } 29 | ], 30 | "editor/title/context": [ 31 | { 32 | "command": "copyRelativePath" 33 | } 34 | ] 35 | } 36 | }, 37 | "scripts": { 38 | "postinstall": "node ./node_modules/vscode/bin/install" 39 | }, 40 | "devDependencies": { 41 | "vscode": "^0.11.0" 42 | }, 43 | "dependencies": { 44 | "copy-paste": "^1.3.0" 45 | }, 46 | "repository": { 47 | "type": "git", 48 | "url": "https://github.com/alexandrudima/vscode-copy-relative-path" 49 | }, 50 | "bugs": { 51 | "url": "https://github.com/alexandrudima/vscode-copy-relative-path/issues" 52 | } 53 | } 54 | --------------------------------------------------------------------------------