Skip to content

Commit

Permalink
Adds open in terminal command to repos
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Jan 5, 2019
1 parent a822544 commit 4b132e0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Added

- Adds pinning of comparisons in the _Compare_ view — pinned comparisons will persist across reloads
- Adds an _Open in Terminal_ command to repositories in the _Repositories_ view

### Fixed

Expand Down
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2247,6 +2247,11 @@
"light": "images/light/icon-push-force.svg"
}
},
{
"command": "gitlens.views.openInTerminal",
"title": "Open in Terminal",
"category": "GitLens"
},
{
"command": "gitlens.views.setAsDefault",
"title": "Set as Default",
Expand Down Expand Up @@ -3083,6 +3088,10 @@
"command": "gitlens.views.pushWithForce",
"when": "false"
},
{
"command": "gitlens.views.openInTerminal",
"when": "false"
},
{
"command": "gitlens.views.setAsDefault",
"when": "false"
Expand Down Expand Up @@ -4332,6 +4341,10 @@
"group": "1_gitlens@2"
},
{
"command": "gitlens.views.openInTerminal",
"when": "viewItem =~ /gitlens:repository\\b/",
"group": "2_gitlens@1"
},
{
"command": "gitlens.openRepoInRemote",
"when": "viewItem =~ /gitlens:repository\\b/ && gitlens:hasRemotes",
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export enum BuiltInCommands {
FocusFilesExplorer = 'workbench.files.action.focusFilesExplorer',
Open = 'vscode.open',
OpenFolder = 'vscode.openFolder',
OpenInTerminal = 'openInTerminal',
NextEditor = 'workbench.action.nextEditor',
PreviewHtml = 'vscode.previewHtml',
RevealLine = 'revealLine',
Expand Down
7 changes: 7 additions & 0 deletions src/views/viewCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export class ViewCommands implements Disposable {
commands.registerCommand('gitlens.views.setAsDefault', this.setAsDefault, this);
commands.registerCommand('gitlens.views.unsetAsDefault', this.unsetAsDefault, this);

commands.registerCommand('gitlens.views.openInTerminal', this.openInTerminal, this);
commands.registerCommand('gitlens.views.star', this.star, this);
commands.registerCommand('gitlens.views.unstar', this.unstar, this);

Expand Down Expand Up @@ -457,6 +458,12 @@ export class ViewCommands implements Disposable {
} as OpenFileInRemoteCommandArgs);
}

private openInTerminal(node: RepositoryNode) {
if (!(node instanceof RepositoryNode)) return;

return commands.executeCommand(BuiltInCommands.OpenInTerminal, Uri.file(node.repo.path));
}

private setAsDefault(node: RemoteNode) {
if (node instanceof RemoteNode) return node.setAsDefault();
return;
Expand Down

0 comments on commit 4b132e0

Please sign in to comment.