Skip to content

Adds custom terminal launch settings - #3495

Merged
Daniel Imms (Tyriar) merged 8 commits into
microsoft:masterfrom
pflannery:open-custom-win-terminal
Apr 18, 2016
Merged

Daniel Imms (Tyriar) merged 8 commits into
microsoft:masterfrom
pflannery:open-custom-win-terminal

Conversation

@pflannery

@pflannery Peter Flannery (pflannery) commented Feb 26, 2016 •

Copy link
Copy Markdown

This allows windows and linux users to specify which terminal they would like to launch when using the browser context menu -> "Open in Command Prompt".
Falls back to the default terminal if no settings specified.

New setting examples:

// Place your settings in this file to overwrite default and user settings.
"terminal.external": {
    "windowsExec": "cmd", // default
    "linuxExec": "x-terminal-emulator" // default for debian, otherwise "gnome-terminal" for gnome desktops
}

Ensures any spawn error is sent to the errors.onUnexpectedError event.

relates to #597

@msftclas

Hi Peter Flannery (@pflannery), I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla.microsoft.com.

TTYL, MSBOT;

@msftclas

Peter Flannery (@pflannery), Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, MSBOT;

@pflannery

Copy link
Copy Markdown
Author

A couple of things

  • I wasn't sure on was how I could add typings for this new setting.
  • I couldn't find any tests for this area so I haven't added a test. So instead I've extracted the dependencies use to spawn into spawnTerminal(...) so its easy to mock in the future

@pflannery

Copy link
Copy Markdown
Author

João Moreno (@joaomoreno) I've added a terminal configuration extension point for windows and linux which allows them to override the default shell launch by vscode.
I wasn't sure what to do for osx as it has script files, so I havent added anything for osx.

@pflannery Peter Flannery (pflannery) changed the title Adds custom terminal launch settings for win Adds custom terminal launch settings Mar 15, 2016
@Tyriar

Copy link
Copy Markdown
Contributor

Peter Flannery (@pflannery) any thoughts on how we could have fallback terminal emulators on Linux? We will eventually want to have at least 2 such as x-terminal-emulator (Debian) and gnome-terminal (Red Hat), probably more eventually as there are other display managers. I'd like to get it so that it works out of the box on Red Hat pretty soon (#4478).

I also noticed while doing a little research in to #4478 that gnome has something similar to the alternatives system in Debian for specifying a preferred terminal:

# Ubuntu
❯ gsettings get org.gnome.desktop.default-applications.terminal exec
'x-terminal-emulator'

# Fedora
❯ gsettings get org.gnome.desktop.default-applications.terminal exec
'gnome-terminal'

@pflannery

Copy link
Copy Markdown
Author

Daniel Imms (@Tyriar) could use process.env.DESKTOP_SESSION === 'gnome'

 - ensures terminal default is used when the terminal setting is removed
@pflannery

Copy link
Copy Markdown
Author

could have powershell as windows default?

@Tyriar

Copy link
Copy Markdown
Contributor

Peter Flannery (@pflannery) nice improvement! Ideally it would only revert to gnome-terminal if it's not Debian based, you could do this by checking if /etc/debian_version exists. Not sure if this is an OK thing to do for default values, but it probably only needs to be done once. João Moreno (@joaomoreno)?

@Tyriar

Copy link
Copy Markdown
Contributor

Peter Flannery (@pflannery) this is more João Moreno (@joaomoreno)'s area, but powershell isn't built into older versions of Windows like 7 is it?

@pflannery

Copy link
Copy Markdown
Author

Daniel Imms (@Tyriar) just looked this up and looks like it's vista backwards that doesn't support powershell out of the box - https://en.wikipedia.org/wiki/Windows_PowerShell#PowerShell_2.0

private spawnTerminal(spawner, configuration, path: string, onExit, onError) {
let terminalConfig = configuration.terminal;
let exec = terminalConfig.linux.exec || defaultLinuxTerm;
const child = spawner.spawn(exec, [], { cwd: path });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does just setting the cwd work with gnome-terminal? You may need to pass in --working-directory=path for that?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node runs gnome-terminal at cwd specified in the options. I tested on Fedora 23 and it does go to the cwd specified. I think it's just a useful flag when someone wants to run from a different path other than the cwd gnome-terminal was executed from.

@joaomoreno

Copy link
Copy Markdown
Contributor

Currently OOF, will check this next week.

Daniel Imms (Tyriar) added a commit that referenced this pull request Mar 24, 2016
A standard Fedora install comes with 2 multiple line environment variables.
Since `env` was previously split by '\n' this would break them, causing
errors in the output pane and in terminals launched through the file
explorer (see #3495).

Fixes #3928
Daniel Imms (Tyriar) added a commit that referenced this pull request Mar 25, 2016
A standard Fedora install comes with 2 multiple line environment variables.
Since `env` was previously split by '\n' this would break them, causing
errors in the output pane and in terminals launched through the file
explorer (see #3495).

The original commit didn't work on OSX since `env` does not support the --null
arg. This version can fail if a command line arg's 1+th line looks like an
environment variable. There is no easy way to prevent this since `process.env`
cannot be leveraged. Since the likelyhood of this happening is small, plus the
chance of it causing any significant issue is also small it's a reasonable
compromise for the time being.

Fixes #3928
Fixes #4672
@Tyriar

Copy link
Copy Markdown
Contributor

Ping João Moreno (@joaomoreno)

* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import fs = require('fs');
import env = require('vs/base/common/platform');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

env -> platform, I think the instances where this is env are older ones that weren't cleaned up

}

export const defaultWindowsTerm = 'cmd'; No newline at end of file
export const DEFAILT_WINDOWS_TERM = 'cmd'; No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo DEFAULT

@@ -0,0 +1,129 @@
/*---------------------------------------------------------------------------------------------

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also live in electron-browser/.

@Tyriar

Copy link
Copy Markdown
Contributor

I think this is good to go other than moving the test to electron-browser/ and the DEFAULT typo.

@Tyriar
Daniel Imms (Tyriar) merged commit dadae2b into microsoft:master Apr 18, 2016
@Tyriar

Copy link
Copy Markdown
Contributor

Love it 😃 Thanks Peter Flannery (@pflannery)! 🎆

@pflannery

Copy link
Copy Markdown
Author

thanks!

@willin

Copy link
Copy Markdown

@trendoid

Copy link
Copy Markdown

I'm just getting to use this today. Thanks Peter Flannery (@pflannery) I love it.

@github-actions github-actions Bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants