Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds custom terminal launch settings #3495

Merged
merged 8 commits into from
Apr 18, 2016
Merged

Adds custom terminal launch settings #3495

merged 8 commits into from
Apr 18, 2016

Conversation

pflannery
Copy link

@pflannery pflannery commented Feb 26, 2016

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
Copy link

Hi @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
Copy link

@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
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
Author

@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 pflannery changed the title Adds custom terminal launch settings for win Adds custom terminal launch settings Mar 15, 2016
@Tyriar
Copy link
Member

Tyriar commented Mar 21, 2016

@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
Author

@Tyriar could use process.env.DESKTOP_SESSION === 'gnome'

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

could have powershell as windows default?

@Tyriar
Copy link
Member

Tyriar commented Mar 21, 2016

@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. @joaomoreno?

@Tyriar
Copy link
Member

Tyriar commented Mar 22, 2016

@pflannery this is more @joaomoreno's area, but powershell isn't built into older versions of Windows like 7 is it?

@pflannery
Copy link
Author

@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
Member

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
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
Member

Currently OOF, will check this next week.

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
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
Member

Tyriar commented Apr 4, 2016

Ping @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
Member

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 DEFAILT_WINDOWS_TERM = 'cmd';
Copy link
Member

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
Member

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
Member

Tyriar commented Apr 18, 2016

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

@Tyriar Tyriar merged commit dadae2b into microsoft:master Apr 18, 2016
@Tyriar
Copy link
Member

Tyriar commented Apr 18, 2016

Love it 😃 Thanks @pflannery! 🎆

@pflannery
Copy link
Author

thanks!

@pflannery pflannery deleted the open-custom-win-terminal branch April 18, 2016 20:20
@willin
Copy link

willin commented Apr 22, 2016

@trendoid
Copy link

I'm just getting to use this today. Thanks @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