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: Use terminal title as the terminal tab title (#1298) #1302

Merged
merged 9 commits into from
Jun 14, 2023

Conversation

Cubik65536
Copy link
Contributor

@Cubik65536 Cubik65536 commented Jun 7, 2023

Signed-off-by: Qian Qian "Cubik"‎ [email protected]

Description

Currently, on the main branch, when we create a terminal in debug area, the title of a terminal tab is always "terminal". This PR changes the current behavior so that when there's no program running, the title is the name of the running shell (e.g. zsh, bash, etc.), and when a program is running, the title changes to the name of running program. That is, unless the user customized the title, then it will not be updated automatically.

Related Issues

Checklist

  • Use a delegate method to update the title when it's changed (as Getting the terminal title on update migueldeicaza/SwiftTerm#302 mentionned, but, this seems not to be what we really want as it does not work with bare terminals).
  • Prevent title from auto updating if the user already changed it (set it to blank means the auto title is used).
  • Set the title to shell name (zsh, bash, etc.) when setting up the terminal (so the shell name will at least stay there if no title updates after that).
  • Use process name instead of the terminal title (at least for the moment) so every shell would work (as discussed in Discord).
    • It's shown in macOS's own Terminal.app (and it's what we want), but it seems that SwiftTerm don't really allow us to get the process name for now. I also created a discussion in SwiftTerm's repo for this.
    • At the end, we didn't do this.
  • Use our own shell script and precmd/preexec function so every shell would work as intended
    • zsh/OhMyZsh
    • bash

  • 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

image

Terminal title after setup process, when no title updates are called.

image

The program name is shown when a program is running. This needs terminal extensions or configurations to work for now.

image

Title shown in <username>@<hostname>:<directory> format when no program is running. (Only when terminal extensions or configurations are added for function above works.) This is not what we really want though. (We want to use the process name, which would show shell name if no program is running.)

image

When no plugin or configuration are added, this won't work (for now) because SwiftTerm's delegate method is not called.

Video Showcase:

2023-06-07.14-28-26.mp4

When the shell is zsh, the terminal title is the program command when an program is running, otherwise it’s “zsh”.

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

Cubik65536 commented Jun 13, 2023

This is what we've got for now (with cb0297a):

2023-06-13.17-08-30.mp4

There is a problem:

  • commands for adding hooks and the clear command following that are in command history
    • they also show themselves for a short time when terminal is created
  • this only works for zsh (and OhMyZsh) for now

@austincondiff
Copy link
Collaborator

If worse comes to worse, as long as bash is titled bash, that is fine for now. Ideally it would work for both but I don't think we should get too hung up on this at this point in the project. We should really focus on our core experience. While our terminal is important, it is secondary to our editing experience. We do need to figure out a way for it to not be in the users history though.

@Cubik65536
Copy link
Contributor Author

If worse comes to worse, as long as bash is titled bash, that is fine for now. Ideally it would work for both but I don't think we should get too hung up on this at this point in the project. We should really focus on our core experience. While our terminal is important, it is secondary to our editing experience. We do need to figure out a way for it to not be in the users history though.

bash can probably work, it just needs a more complicated script, we are looking into it, i think it can be done soon

@Cubik65536
Copy link
Contributor Author

@austincondiff bash part is also done 🎉

@Cubik65536 Cubik65536 marked this pull request as ready for review June 13, 2023 23:09
@Cubik65536
Copy link
Contributor Author

2023-06-13.19-10-49.mp4

Copy link
Collaborator

@austincondiff austincondiff left a comment

Choose a reason for hiding this comment

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

Beautiful! Great work @Cubik65536!

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.

Look good! Thanks for putting in the work on this one and for being patient!

@bombardier200 bombardier200 merged commit 228d23a into CodeEditApp:main Jun 14, 2023
@Cubik65536 Cubik65536 deleted the feat-terminal-title-change branch June 14, 2023 17:32
@austincondiff
Copy link
Collaborator

@allcontributors add @Cubik65536 for code

@allcontributors
Copy link
Contributor

@austincondiff

I've put up a pull request to add @Cubik65536! 🎉

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.

✨ Use terminal title as the terminal tab title
3 participants