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

Setting terminal window title #2200

Merged
merged 6 commits into from Apr 19, 2022
Merged

Setting terminal window title #2200

merged 6 commits into from Apr 19, 2022

Conversation

darrenburns
Copy link
Member

@darrenburns darrenburns commented Apr 19, 2022

Type of changes

  • Bug fix
  • New feature
  • Documentation / docstrings
  • Tests
  • Other

Checklist

  • I've run the latest black with default args on new code.
  • I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • I've added tests for new code.
  • I accept that @willmcgugan may be pedantic in the code review.

Description

Adds support for setting the title of the terminal window.

There is no means within Rich of "resetting" the window title to its
previous value, meaning the title you set will persist even after your application
exists.

fish shell resets the window title before and after each command by default,
negating this issue. Windows Terminal and command prompt will also reset the title for you.
Most other shells and terminals, however, do not do this.

Some terminals may require configuration changes before you can set the title.
Some terminals may not support setting the title at all.

Other software (including the terminal itself, the shell, custom prompts, plugins, etc.)
may also set the terminal window title. This could result in whatever value you write
using this method being overwritten.

@codecov-commenter
Copy link

codecov-commenter commented Apr 19, 2022

Codecov Report

Merging #2200 (a937b5b) into master (7105781) will decrease coverage by 0.52%.
The diff coverage is 86.05%.

@@            Coverage Diff             @@
##           master    #2200      +/-   ##
==========================================
- Coverage   99.46%   98.94%   -0.53%     
==========================================
  Files          72       73       +1     
  Lines        7339     7606     +267     
==========================================
+ Hits         7300     7526     +226     
- Misses         39       80      +41     
Flag Coverage Δ
unittests 98.94% <86.05%> (-0.53%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
rich/__main__.py 100.00% <ø> (ø)
rich/layout.py 100.00% <ø> (ø)
rich/markup.py 100.00% <ø> (ø)
rich/progress.py 92.77% <78.85%> (-5.66%) ⬇️
rich/progress_bar.py 99.00% <85.71%> (-1.00%) ⬇️
rich/console.py 98.89% <96.62%> (-0.26%) ⬇️
rich/__init__.py 100.00% <100.00%> (ø)
rich/_export_format.py 100.00% <100.00%> (ø)
rich/_windows_renderer.py 100.00% <100.00%> (ø)
rich/control.py 100.00% <100.00%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3b36864...a937b5b. Read the comment docs.

@@ -51,3 +51,6 @@ def legacy_windows_render(buffer: Iterable[Segment], term: LegacyWindowsTerm) ->
term.erase_start_of_line()
elif mode == 2:
term.erase_line()
elif control_type == ControlType.SET_WINDOW_TITLE:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great! Did you test this on the Windows laptop?

Copy link
Member Author

Choose a reason for hiding this comment

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

I did yeah, works well there. It even automatically resets the title on both Windows Terminal and legacy Windows, so it's actually even better.

Copy link
Collaborator

@willmcgugan willmcgugan left a comment

Choose a reason for hiding this comment

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

LGTM

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.

None yet

3 participants