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

Simplify shell integration manual install by deferring to the code CLI #153921

Closed
Tyriar opened this issue Jul 1, 2022 · 6 comments · Fixed by #155046 or #155523
Closed

Simplify shell integration manual install by deferring to the code CLI #153921

Tyriar opened this issue Jul 1, 2022 · 6 comments · Fixed by #155046 or #155523
Assignees
Labels
feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders on-testplan terminal-shell-integration Shell integration, command decorations, etc. workbench-cli VS Code Command line issues
Milestone

Comments

@Tyriar
Copy link
Member

Tyriar commented Jul 1, 2022

Currently install is a little cumbersome, for example:

Add the following to your PowerShell profile, replacing <InstallDir> with VS Code's installation directory. Run code $Profile in pwsh to open the file in VS Code.

if ($env:TERM_PROGRAM -eq "vscode") {
 . "<InstallDir>\resources\app\out\vs\workbench\contrib\terminal\browser\media\shellIntegration.ps1"
}

It would be much nicer if this was encapsulated within the CLI, something like:

code shell-integration

We should also make sure these cases are covered:

  • Remote development extensions - injection works currently but manual install doesn't talk about the server paths
  • Regular SSH - it's not so easy to get the shell integration script to the remote machine
@Tyriar Tyriar added feature-request Request for new features or functionality workbench-cli VS Code Command line issues terminal-shell-integration Shell integration, command decorations, etc. labels Jul 1, 2022
@Tyriar Tyriar added this to the July 2022 milestone Jul 1, 2022
@FranklinYu
Copy link

Hi, I’m thinking about another way, in addition to the CLI mentioned above: how about creating a package (deb/rpm) with only https://github.com/microsoft/vscode/tree/main/src/vs/workbench/contrib/terminal/browser/media directory? This way I only need to install this on the server if I want to SSH to it without remote development (assuming that for some reason I don’t want remote development), since I don’t need the other part of VS Code. This can even go into Debian/Fedora because it is pure MIT, and the package doesn’t have any dependency.

I understand that this won’t serve all users (e.g. Windows Server users), so the CLI-way still works as a catch-all.

@Tyriar
Copy link
Member Author

Tyriar commented Jul 8, 2022

The deb/rpm approach isn't great as that's a bunch of overhead building and maintaining the packages, additionally if we keep the script bundled with VS Code then we're able to make breaking changes without many consequences, even new features could break old version of VS Code so it's best to keep them in sync using the same package. I'll think about how we can support SSH better when not using the Remote - SSH extension.

Now that you remote, I realize the remote development case isn't covered by manual install currently as it uses desktop paths, we'll need to make sure that's covered as well.

@felipecrs
Copy link
Contributor

felipecrs commented Jul 11, 2022

The installation instructions at the link below are broken for what I have tested (Linux local and Remote):

https://code.visualstudio.com/docs/editor/terminal-shell-integration#_manual-installation:~:text=media%5CshellIntegration.ps1%22%0A%7D-,LINUX%20AND%20MACOS,-The%20script%20below

When inside Remote - WSL or Remote - SSH (probably Containers too), the Resources Dir can be found with:

- echo "$(readlink -f "$(which code)")../resources"
+ realpath "$(dirname "$(command -v code)")/../../resources"
  • command -v vs which: https://www.shellcheck.net/wiki/SC2230

  • dirname is required to step back a folder from a file (code/.. fails)

  • calling realpath is better than readlink -f since it at least warns the user if the path can't be resolved.

  • echo isn't required

In such case, the latter snippet also needs to be adjusted:

if [ "$TERM_PROGRAM" == "vscode" ]; then
-   . <InstallDir>/app/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh
+   . <InstallDir>/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh
fi

And when not running through Remote, I wasn't able to find such a file in a Linux .deb installation. Even by following the original instructions, which would probably resolve to a path like: /usr/bin/resources which isn't valid too.

The correct path would be /usr/share/code/resources instead. And, in such case, the latter snippet would be correct.

@Tyriar
Copy link
Member Author

Tyriar commented Jul 13, 2022

@felipecrs thanks for the info, this is what we're planning for the improved experience in #155046:

# pwsh
if ($s=$(code --shell-integration pwsh)) { . $s }
# bash
. "$(code --shell-integration bash)"

# zsh
. "$(code --shell-integration zsh)"

This will also work on the server so the remote extensions will be covered the same.

@VSCodeTriageBot VSCodeTriageBot added the unreleased Patch has not yet been released in VS Code Insiders label Jul 14, 2022
Tyriar added a commit to microsoft/vscode-docs that referenced this issue Jul 14, 2022
Tyriar added a commit to microsoft/vscode-docs that referenced this issue Jul 14, 2022
@VSCodeTriageBot VSCodeTriageBot added insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Jul 15, 2022
Tyriar added a commit that referenced this issue Jul 18, 2022
Tyriar added a commit that referenced this issue Jul 19, 2022
Tyriar added a commit that referenced this issue Jul 19, 2022
Tyriar added a commit to microsoft/vscode-docs that referenced this issue Jul 19, 2022
@joaomoreno
Copy link
Member

@Tyriar I'm actually worried about perf here. Running code --shell-integration will be slow in many systems, slow enough to notice lag when launching a shell.

Given that this always returns the same value every time we execute it... could we perhaps do something similar to macOS's CLI install command?

@Tyriar
Copy link
Member Author

Tyriar commented Jul 21, 2022

@joaomoreno installing it directly like the command there isn't portable across system though. We are looking into having the code CLI redone in rust which will make it plenty fast enough as we won't need to launch node.

I also considered having it in the .sh file itself, but that wouldn't work unless the cli is sourced, not run, and it also wouldn't work at all in pwsh since our CLI is a batch script.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders on-testplan terminal-shell-integration Shell integration, command decorations, etc. workbench-cli VS Code Command line issues
Projects
None yet
6 participants