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

Stop Modifying User's RC Files #1753

Merged

Conversation

thecoolwinter
Copy link
Collaborator

Description

Updates our terminal integration to be a little more clever about injections. Introduces a ShellIntegration enum, which contains functions for setting up a pseudo terminal for supported shells.

Introduces a method for each shell for injecting our pre/post exec handlers:

  • zsh
    • Creates a temporary directory for the user and moves all our .zsh injection files into that temp folder.
    • Each .zsh injection file is an override for zsh's real init files (.zprofile, .zshenv, .zshrc, .zlogin).
    • Before initiating the terminal, we grab the user's zdotdir env variable and store it, replacing it with our own pointing to the temporary directory.
    • In each of CodeEdit's injected .zshX files, we source the user's real zsh init files exactly how zsh does it.
    • Then, in .zshrc, we do our injection code.
  • bash
    • We make use of the --init-file parameter for bash. Creating a new, interactive session using our own init file.
    • This init file also emulates exactly what bash would do upon init, sourcing the user's profile or .bashrc depending on if the session is a login session.
    • After initializing the session with the correct information, we install our pre/post exec functions.

These borrow some MIT-licensed code from VSCode and are documented as such, with permalinks to the source files.

Finally, because we're doing this at runtime we can allow users to opt-out of the injection mechanism in settings.

Related Issues

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

Before (zsh example):

Screen.Recording.2024-06-12.at.4.48.06.PM.mov

After: init files still being sourced, not modifying the user's init files, and terminal titles still working.

Zsh:

Screen.Recording.2024-06-12.at.5.10.11.PM.mov

Bash:

Screen.Recording.2024-06-12.at.5.08.26.PM.mov

Copy link
Contributor

@bombardier200 bombardier200 left a comment

Choose a reason for hiding this comment

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

Great work! Always good to fix a privacy issue!

@bombardier200 bombardier200 merged commit 23edf0e into CodeEditApp:main Jun 13, 2024
2 checks passed
@thecoolwinter thecoolwinter added the enhancement New feature or request label Jul 19, 2024
@thecoolwinter thecoolwinter deleted the fix/modifying-users-intifiles branch July 20, 2024 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request terminal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ Stop editing users zsh file in order to set the terminal tab title
3 participants