From ffef5c64fafa17f6cd7ad003bfbd85366426cfa4 Mon Sep 17 00:00:00 2001 From: Kelvin Schoofs Date: Wed, 8 Jul 2020 19:58:34 +0200 Subject: [PATCH] Add "Open remote SSH terminal" in explorer for ssh:// directories + make root-sensitive --- README.md | 8 ++++++-- media/explorer-terminal.png | Bin 0 -> 21774 bytes package.json | 9 ++++++++- src/extension.ts | 15 ++++++++++++++- src/manager.ts | 22 +++++++++++++++++----- src/pseudoTerminal.ts | 4 +++- 6 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 media/explorer-terminal.png diff --git a/README.md b/README.md index d3851ec..f4e1d36 100644 --- a/README.md +++ b/README.md @@ -47,12 +47,16 @@ The configurations for SSH file systems can now also be used to spawn terminals: ![Terminals](./media/terminals.png) -Currently the working directory will always be the user's home directory, similar to directly connecting to the server over ssh. I'm thinking about making it automatically move to the `root` directory if possible. +Opening a terminal automatically sets the working directory to the `root` directory, unless a directory was explicitly selected to open the terminal in: + +![Explorer Terminal](./media/explorer-terminal.png) + +This replaces the built-in "Open terminal" context menu option that isn't provided for remote field systems. For non-ssh:// file systems, the original "Open terminal" menu item is still displayed, the remote version only affects ssh:// file systems. ### New task type This extension adds a new task type `ssh-shell` which can be used to run commands on a configured remote host: -![Terminals](./media/tasks.png) +![Tasks](./media/tasks.png) Currently only the `command` field is supported. The goal is to replicate part of the `shell` task structure, e.g. an `args` array, support for `${workspaceFolder}`, ... diff --git a/media/explorer-terminal.png b/media/explorer-terminal.png new file mode 100644 index 0000000000000000000000000000000000000000..bf443d2717338b09c0a5eb4dc1506470c73cbc55 GIT binary patch literal 21774 zcmbrmc|4SF*fx&HzKmt4h#6xyL{cdGFhcfitl6@r5XrvFSY`%Elx-+`){rGz#+E%> zB_cZ|ge>npsqgcBpZ9s+-}8KafAs0Y+;iX8eO=dip2u;V$K|2!4Rv~&vos_mB=j0c zRecf?GIkOY(p)Ms;5STESu?`&MgD zgX1zf{icWUFFuYW(2LXr8De>RuIo`I2u_s?SJP|BXf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56Z-pUaLj~R0(On`3on!Hhc zV-+ARv`DM2u}}DS1~(5&Is*K-`Qfj=ABztUV@?bOU9K(V)iVx@bS@d4DU{k9rwV*b zjG&d?Rj#Nw{`TZZdcl~6BIX*b@V&6h5xuw1F7yc1;Z}ud5;BCa0H$6uk|_J zYC?3tYI32^fpp{5KQtG>%(xrNXV}N}PRq^BA=8NP*e5~G)GR|tg^$H6OEmkOdJ)u`f5TScSW2>OvA6-H+$~=pHTLJ3^lzF5vPnIKDvJ5j>0(X; zl^NL=?RukCPoA>1nTV9W_7(N9<^s6X>x~E2AI%0Ol%DRxS*| zp$tSVc?i1W9>j7H#$Wo8!SocYfp`PHlGhcFYdT*NsOnLbcHmLRGjl$54cmkX*I&Ub zFh_ba*}0hk!FwL9kJ!rW48XHS)M*>E-&SPS_hoLwAFxjBEthEIf1!p!$Ucpi0JV^E z^;6U4*ZF6JB9hiQDQox}Wm9{53YM-bd`2!h76V+2Q=Z5fzcQ~y%4lwp>_s!b@4POM zeJ{#K6MuGXgq~~V9q&E&c@^gv+<$4$b1O<7WM@A#3_mNZgcfpPTDjnja~CPOFn@5F z;*bzW9T@3AfV;CG9%-B2FZ*&4hGrY@Eez1uUs!yfc8K<(6-E*L%Pe#SKZl4uQhDF* z9CeiB^D|&754*N+mw~y4a}5yLODz36#;hf(jP^3 z$(SS1$w)Kn-Ghu#1@J`f1K7h#d`rKfH=ucV1D@rglMgt0h)bxO|Lf7q^FS+S7YkJa zo?7g0V2XW^J12T}BdwbgEfXhhWUEQo;$7=nRjlOX_vT?wS=S;VqU{*w;`4>5-h}@j o)9G4ab6U pickAndClick(manager.commandConnect, name, false)); registerCommand('sshfs.disconnect', (name?: string | FileSystemConfig) => pickAndClick(manager.commandDisconnect, name, true)); registerCommand('sshfs.reconnect', (name?: string | FileSystemConfig) => pickAndClick(manager.commandReconnect, name, true)); - registerCommand('sshfs.terminal', (name?: string | FileSystemConfig) => pickAndClick(manager.commandTerminal, name)); + registerCommand('sshfs.terminal', async (configOrUri?: string | FileSystemConfig | vscode.Uri) => { + // SSH FS view context menu: [ config, null ] + // Explorer context menu: [ uri, [uri] ] + // Command: [ ] + // And just in case, supporting [ configName ] too + let config = configOrUri; + let uri: vscode.Uri | undefined; + if (config instanceof vscode.Uri) { + uri = config; + config = config.authority; + } + config = config || await pickConfig(manager); + if (config) manager.commandTerminal(config, uri); + }); registerCommand('sshfs.configure', (name?: string | FileSystemConfig) => pickAndClick(manager.commandConfigure, name)); registerCommand('sshfs.reload', loadConfigs); diff --git a/src/manager.ts b/src/manager.ts index cb17563..03c9814 100644 --- a/src/manager.ts +++ b/src/manager.ts @@ -7,6 +7,7 @@ import { Logging } from './logging'; import { createTaskTerminal, SSHPseudoTerminal } from './pseudoTerminal'; import { catchingPromise, toPromise } from './toPromise'; import { Navigation } from './webviewMessages'; +import * as path from 'path'; type SSHFileSystem = import('./sshFileSystem').SSHFileSystem; @@ -234,14 +235,25 @@ export class Manager implements vscode.TreeDataProvider { + public async createTerminal(name: string, config?: FileSystemConfig, uri?: vscode.Uri): Promise { const { createTerminal } = await import('./pseudoTerminal'); + // Create connection (early so we have .actualConfig.root) const con = await this.createConnection(name, config); + // Calculate working directory if applicable + let workingDirectory: string | undefined = uri ? uri.path : con.actualConfig.root || '/'; + if (workingDirectory) { + // Normally there should be a fs, as (currently) workingDirectory is only provided + // when the user uses "Open remote SSH terminal" on a directory in the explorer view + const fs = this.fileSystems.find(fs => fs.config.name === name); + workingDirectory = fs ? fs.relative(workingDirectory) : undefined; + } + // Create pseudo terminal con.pendingUserCount++; - const pty = await createTerminal(con.client, con.actualConfig); + const pty = await createTerminal(con.client, con.actualConfig, workingDirectory); pty.onDidClose(() => con.terminals = con.terminals.filter(t => t !== pty)); con.terminals.push(pty); con.pendingUserCount--; + // Create and show the graphical representation const terminal = vscode.window.createTerminal({ name, pty }); terminal.show(); } @@ -355,11 +367,11 @@ export class Manager implements vscode.TreeDataProvider { +export async function createTerminal(client: Client, config: FileSystemConfig, workingDirectory?: string): Promise { const channel = await toPromise(cb => client.shell(PSEUDO_TTY_OPTIONS, cb)); if (!channel) throw new Error('Could not create remote terminal'); const onDidWrite = new vscode.EventEmitter(); @@ -28,6 +28,8 @@ export async function createTerminal(client: Client, config: FileSystemConfig): channel.on('exit', onDidClose.fire); // Hopefully the exit event fires first channel.on('close', () => onDidClose.fire(0)); + // There isn't a proper way of setting the working directory, but this should work in most cases + if (workingDirectory) channel.write(`cd "${workingDirectory}"\n`); const pseudo: SSHPseudoTerminal = { config, client, channel, onDidWrite: onDidWrite.event,