Skip to content

Commit

Permalink
Merge pull request #2 from rwietter/feat/urxvt
Browse files Browse the repository at this point in the history
docs: add rxvt-unicote and adjust README and package.json
  • Loading branch information
rwietter authored Dec 18, 2023
2 parents 8e57a65 + 4227441 commit d985e04
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 39 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Exterm arose from the need to open the terminal and navigate through directories

Exterm adds an item to the explorer/context menu of VS Code. When right-clicking on a directory, it opens the terminal directly in that directory.

> **Note**: At the moment, Exterm is under development (it has not yet been published on the marketplace).
## Installation

To install Exterm, you need to have [VS Code](https://code.visualstudio.com/) installed and follow the steps below:
Expand All @@ -27,6 +29,7 @@ By default, Exterm uses the terminal [wezterm](https://wezfurlong.org/wezterm/),
- [alacritty](https://github.com/alacritty/alacritty)
- [kitty](https://github.com/kovidgoyal/kitty)
- [kermit](https://github.com/orhun/kermit)
- [rxvt-unicode](http://software.schmorp.de/pkg/rxvt-unicode.html)

**Windows**

Expand All @@ -52,7 +55,7 @@ To make Exterm open your preferred terminal, you need to configure it in the VS

To use Exterm, open the explorer/context menu of VS Code, right-click on a directory, and click on "Open in terminal," as shown in the image below:

![Exterm](https://raw.githubusercontent.com/eduardo3g/exterm/main/images/exterm.png)
![Exterm]()

## Contributing

Expand Down
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
"commands": [
{
"command": "exterm.openProjectInExternalTerminal",
"title": "exterm: Open Project in External Terminal"
},
{
"command": "exterm.helloWorld",
"title": "Hello World"
"title": "Exterm: Open in External Terminal"
}
],
"configuration": {
Expand All @@ -38,6 +34,7 @@
"konsole",
"xfce4-terminal",
"kermit",
"urxvt",
"cmd.exe"
],
"default": "wezterm",
Expand All @@ -50,7 +47,7 @@
{
"when": "explorerResourceIsFolder",
"command": "exterm.openProjectInExternalTerminal",
"group": "exterm@1"
"group": "navigation"
}
]
}
Expand Down
45 changes: 23 additions & 22 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,41 @@ import * as vscode from 'vscode';
import * as cp from 'child_process';

const supportedTerminals = {
'kitty': '-d',
'gnome-terminal': '--working-directory',
'xfce4-terminal': '--working-directory',
'alacritty': '--working-directory',
'kermit': '-w',
'wezterm': 'start --cwd',
'cmd.exe': '/c', // TODO: test this flag
'kitty': '-d',
'gnome-terminal': '--working-directory',
'xfce4-terminal': '--working-directory',
'alacritty': '--working-directory',
'kermit': '-w',
'wezterm': 'start --cwd',
'urxvt': '-cd',
'cmd.exe': '/c', // TODO: test this flag
}

type TerminalKind = keyof typeof supportedTerminals;

export function activate(context: vscode.ExtensionContext) {
let openProjectInExternalTerminal = vscode.commands.registerCommand('exterm.openProjectInExternalTerminal', (uri: vscode.Uri | undefined) => {
let openProjectInExternalTerminal = vscode.commands.registerCommand('exterm.openProjectInExternalTerminal', (uri: vscode.Uri | undefined) => {

if (!uri) return vscode.window.showInformationMessage('No directory or file selected.');
if (!uri) return vscode.window.showInformationMessage('No directory or file selected.');

const defaultPlatformTerminalCommand = process.platform === 'win32' ? 'cmd.exe' : 'kitty';
const terminalConfig = vscode.workspace.getConfiguration('exterm');
const userTerm: TerminalKind | undefined = terminalConfig.get('terminalKind');
const defaultPlatformTerminalCommand = process.platform === 'win32' ? 'cmd.exe' : 'kitty';
const terminalConfig = vscode.workspace.getConfiguration('exterm');
const userTerm: TerminalKind | undefined = terminalConfig.get('terminalKind');

let terminalKind: TerminalKind = userTerm || defaultPlatformTerminalCommand
let flagDirectory = supportedTerminals[terminalKind];
let directoryPath = uri.fsPath;
let terminalKind: TerminalKind = userTerm || defaultPlatformTerminalCommand
let flagDirectory = supportedTerminals[terminalKind];
let directoryPath = uri.fsPath;

vscode.window.showInformationMessage(`Opening ${directoryPath} in ${terminalKind}...`);
vscode.window.showInformationMessage(`Opening ${directoryPath} in ${terminalKind}...`);

cp.spawn(terminalKind, [flagDirectory, directoryPath], {
detached: false,
shell: true,
windowsHide: false
});
cp.spawn(terminalKind, [flagDirectory, directoryPath], {
detached: false,
shell: true,
windowsHide: false
});
});

context.subscriptions.push(openProjectInExternalTerminal);
context.subscriptions.push(openProjectInExternalTerminal);
}

export function deactivate() { }
10 changes: 0 additions & 10 deletions src/open_terminal.sh

This file was deleted.

0 comments on commit d985e04

Please sign in to comment.