MCPcopy
hub / github.com/Textualize/rich / set_window_title

Method set_window_title

rich/console.py:1231–1261  ·  view source on GitHub ↗

Set the title of the console terminal window. Warning: 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 exits. ``fish`` shell resets the window title before and af

(self, title: str)

Source from the content-addressed store, hash-verified

1229 return self._is_alt_screen
1230
1231 def set_window_title(self, title: str) -> bool:
1232 """Set the title of the console terminal window.
1233
1234 Warning: There is no means within Rich of "resetting" the window title to its
1235 previous value, meaning the title you set will persist even after your application
1236 exits.
1237
1238 ``fish`` shell resets the window title before and after each command by default,
1239 negating this issue. Windows Terminal and command prompt will also reset the title for you.
1240 Most other shells and terminals, however, do not do this.
1241
1242 Some terminals may require configuration changes before you can set the title.
1243 Some terminals may not support setting the title at all.
1244
1245 Other software (including the terminal itself, the shell, custom prompts, plugins, etc.)
1246 may also set the terminal window title. This could result in whatever value you write
1247 using this method being overwritten.
1248
1249 Args:
1250 title (str): The new title of the terminal window.
1251
1252 Returns:
1253 bool: True if the control code to change the terminal title was
1254 written, otherwise False. Note that a return value of True
1255 does not guarantee that the window title has actually changed,
1256 since the feature may be unsupported/disabled in some terminals.
1257 """
1258 if self.is_terminal:
1259 self.control(Control.title(title))
1260 return True
1261 return False
1262
1263 def screen(
1264 self, hide_cursor: bool = True, style: Optional[StyleType] = None

Callers 2

test_set_console_titleFunction · 0.95
control.pyFile · 0.80

Calls 2

controlMethod · 0.95
titleMethod · 0.80

Tested by 1

test_set_console_titleFunction · 0.76