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

feat: Improve Shell Integration Setup Process (#1387) #1388

Merged

Conversation

Cubik65536
Copy link
Contributor

Description

In PR #1298 , some commands are executed automatically when creating a new terminal to let the terminal title change according to the program running. But these commands will be shown to the user during the setup process.

In this PR, I moved the shell integration setup commands into user's shell's source files (~/.zshrc, ~/.profile, etc.) and moved the shell integration check & install into a dedicated function directly in our App (instead of having an shell script), so no commands needs to be executed in user's terminal when it's created.

This is briefly how it works:

  1. The user created a terminal
  2. A function is called to check if the user have our shell integration installed
    • If it's installed, nothing happens because our script is already sourced for every terminal running inside CodeEdit.
    • If it's not, add the source command in user's source file. It's done before the real terminal have been created, so the terminal created right after that and every other terminal created later will have the correct script sourced.

This still works for both zsh (with or without ohmyzsh) and bash.

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

2023-07-20.15-11-59.mp4

@Cubik65536
Copy link
Contributor Author

P.S.: TERM_PROGRAM was set to CodeEditApp_Terminal because it's used to identify if the shell is running in CodeEdit App, and the scripts added into user's source file will only work when TERM_PROGRAM is CodeEditApp_Terminal to reduce impact on other programs.

Copy link
Contributor

@matthijseikelenboom matthijseikelenboom left a comment

Choose a reason for hiding this comment

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

I suspect this also removes the annoying 'source' command that gets added to the terminal history?

@Cubik65536
Copy link
Contributor Author

I suspect this also removes the annoying 'source' command that gets added to the terminal history?

Yes

0xWDG
0xWDG previously approved these changes Jul 27, 2023
@bombardier200
Copy link
Contributor

@Cubik65536 can you fix swiftlint errors?

Signed-off-by: Qian Qian "Cubik"‎ <[email protected]>
@Cubik65536
Copy link
Contributor Author

@Cubik65536 can you fix swiftlint errors?

I pushed a fix

Signed-off-by: Qian Qian "Cubik"‎ <[email protected]>
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.

Good work!

@bombardier200 bombardier200 merged commit b2b2c0b into CodeEditApp:main Aug 2, 2023
2 checks passed
@Cubik65536 Cubik65536 deleted the feat/improve-terminal-integration branch August 3, 2023 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ Hide terminal title change command while creating new terminal
5 participants