-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
67 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,9 @@ | ||
# vscode-open-in-file-manager README | ||
<p align="center"> | ||
<img src="https://github.com/13ruceYu/vscode-open-in-file-manager/blob/master/res/icon.png?raw=true" height="150" alt="icon"> | ||
</p> | ||
|
||
This is the README for your extension "vscode-open-in-file-manager". After writing up a brief description, we recommend including the following sections. | ||
|
||
## Features | ||
|
||
Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file. | ||
|
||
For example if there is an image subfolder under your extension project workspace: | ||
|
||
\!\[feature X\]\(images/feature-x.png\) | ||
|
||
> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow. | ||
## Requirements | ||
|
||
If you have any requirements or dependencies, add a section describing those and how to install and configure them. | ||
|
||
## Extension Settings | ||
|
||
Include if your extension adds any VS Code settings through the `contributes.configuration` extension point. | ||
|
||
For example: | ||
|
||
This extension contributes the following settings: | ||
|
||
* `myExtension.enable`: Enable/disable this extension. | ||
* `myExtension.thing`: Set to `blah` to do something. | ||
|
||
## Known Issues | ||
|
||
Calling out known issues can help limit users opening duplicate issues against your extension. | ||
|
||
## Release Notes | ||
|
||
Users appreciate release notes as you update your extension. | ||
|
||
### 1.0.0 | ||
|
||
Initial release of ... | ||
|
||
### 1.0.1 | ||
|
||
Fixed issue #. | ||
|
||
### 1.1.0 | ||
|
||
Added features X, Y, and Z. | ||
|
||
--- | ||
|
||
## Following extension guidelines | ||
|
||
Ensure that you've read through the extensions guidelines and follow the best practices for creating your extension. | ||
|
||
* [Extension Guidelines](https://code.visualstudio.com/api/references/extension-guidelines) | ||
|
||
## Working with Markdown | ||
|
||
You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts: | ||
|
||
* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux). | ||
* Toggle preview (`Shift+Cmd+V` on macOS or `Shift+Ctrl+V` on Windows and Linux). | ||
* Press `Ctrl+Space` (Windows, Linux, macOS) to see a list of Markdown snippets. | ||
|
||
## For more information | ||
|
||
* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown) | ||
* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/) | ||
<p align="center"> | ||
Add a button to open file manager(finder, file explorer) on the status bar. | ||
</p> | ||
|
||
**Enjoy!** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,32 @@ | ||
{ | ||
"name": "vscode-open-in-file-manager", | ||
"displayName": "vscode-open-in-file-manager", | ||
"description": "", | ||
"name": "open-in-file-manager", | ||
"displayName": "Open in File Manager", | ||
"description": "Add a button to open file manager(finder, file explorer) on the status bar", | ||
"version": "0.0.1", | ||
"author": "Bruce Yu <[email protected]>", | ||
"publisher": "bruceyuhb", | ||
"homepage": "https://github.com/13ruceYu/vscode-open-in-file-manager#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/13ruceYu/vscode-open-in-file-manager" | ||
}, | ||
"icon": "res/icon.png", | ||
"license": "MIT", | ||
"engines": { | ||
"vscode": "^1.96.0" | ||
}, | ||
"categories": [ | ||
"Other" | ||
], | ||
"activationEvents": [], | ||
"activationEvents": [ | ||
"onStartupFinished" | ||
], | ||
"main": "./out/extension.js", | ||
"contributes": { | ||
"commands": [ | ||
{ | ||
"command": "vscode-open-in-file-manager.helloWorld", | ||
"title": "Hello World" | ||
"command": "extension.openInFileManager", | ||
"title": "Open in File Manager" | ||
} | ||
] | ||
}, | ||
|
@@ -38,4 +49,4 @@ | |
"@vscode/test-cli": "^0.0.10", | ||
"@vscode/test-electron": "^2.4.1" | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,51 @@ | ||
// The module 'vscode' contains the VS Code extensibility API | ||
// Import the module and reference it with the alias vscode in your code below | ||
import * as vscode from 'vscode'; | ||
|
||
// This method is called when your extension is activated | ||
// Your extension is activated the very first time the command is executed | ||
function getFileManagerName() { | ||
switch (process.platform) { | ||
case 'darwin': // macOS | ||
return 'Finder'; | ||
case 'win32': // Windows | ||
return 'File Explorer'; | ||
case 'linux': // Linux | ||
return 'File Manager'; | ||
default: | ||
return 'File Manager'; | ||
} | ||
} | ||
|
||
export function activate(context: vscode.ExtensionContext) { | ||
const fileManagerName = getFileManagerName(); | ||
|
||
const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 0); | ||
statusBarItem.text = "$(file-symlink-directory)"; | ||
statusBarItem.tooltip = `Reveal Workspace in ${fileManagerName}`; | ||
statusBarItem.command = "extension.revealWorkspaceInFileManager"; | ||
statusBarItem.show(); | ||
|
||
context.subscriptions.push(statusBarItem); | ||
|
||
const revealCommand = vscode.commands.registerCommand("extension.revealWorkspaceInFileManager", () => { | ||
const workspaceFolders = vscode.workspace.workspaceFolders; | ||
|
||
if (!workspaceFolders || workspaceFolders.length === 0) { | ||
vscode.window.showErrorMessage('No workspace folder is open.'); | ||
return; | ||
} | ||
|
||
// Use the console to output diagnostic information (console.log) and errors (console.error) | ||
// This line of code will only be executed once when your extension is activated | ||
console.log('Congratulations, your extension "vscode-open-in-file-manager" is now active!'); | ||
const workspaceUri = workspaceFolders[0].uri; | ||
|
||
// The command has been defined in the package.json file | ||
// Now provide the implementation of the command with registerCommand | ||
// The commandId parameter must match the command field in package.json | ||
const disposable = vscode.commands.registerCommand('vscode-open-in-file-manager.helloWorld', () => { | ||
// The code you place here will be executed every time your command is executed | ||
// Display a message box to the user | ||
vscode.window.showInformationMessage('Hello World from vscode-open-in-file-manager!'); | ||
}); | ||
vscode.commands.executeCommand('revealFileInOS', workspaceUri).then( | ||
() => { | ||
console.log(`Revealed workspace folder in ${fileManagerName}`); | ||
}, | ||
(err) => { | ||
console.error(`Failed to reveal folder in ${fileManagerName}:`, err); | ||
vscode.window.showErrorMessage(`Failed to reveal workspace folder in ${fileManagerName}.`); | ||
} | ||
); | ||
}); | ||
|
||
context.subscriptions.push(disposable); | ||
context.subscriptions.push(revealCommand); | ||
} | ||
|
||
// This method is called when your extension is deactivated | ||
export function deactivate() {} | ||
export function deactivate() { } |