diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..5d47c21 --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/README.md b/README.md index dbe6211..bd6ecb4 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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** @@ -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 diff --git a/package.json b/package.json index fb4c8e8..9c3deb2 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -38,6 +34,7 @@ "konsole", "xfce4-terminal", "kermit", + "urxvt", "cmd.exe" ], "default": "wezterm", @@ -50,7 +47,7 @@ { "when": "explorerResourceIsFolder", "command": "exterm.openProjectInExternalTerminal", - "group": "exterm@1" + "group": "navigation" } ] } diff --git a/src/extension.ts b/src/extension.ts index 48e95b3..868ee4a 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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() { } diff --git a/src/open_terminal.sh b/src/open_terminal.sh deleted file mode 100644 index 9e213dd..0000000 --- a/src/open_terminal.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -# Obtém o caminho do diretório do primeiro workspace do VS Code -WORKSPACE_PATH="$(jq -r '.folders[0].uri' <<< $(code --list-workspaces))" - -# Navega até o diretório do workspace -cd "$WORKSPACE_PATH" || exit - -# Abre o WezTerm -wezterm