Skip to content

Commit cfd087a

Browse files
committed
Fix terminal tab title not resetting after pager commands
Programs like git diff, less, and vim use alternate screen mode and can set the terminal title. Ghostty doesn't support title push/pop (CSI 22/23), so titles weren't restored on exit. Ghostty's shell integration has a title feature that should reset the title at the prompt, but Starship overwrites PS1 entirely, wiping out those escape sequences. Solution: - Add [custom.window_title] module in starship.toml that sets the window title using `starship module directory` for consistent formatting - Disable Ghostty's title feature (no-title) since Starship now handles it Ref: ghostty-org/ghostty#2667
1 parent 0a3324a commit cfd087a

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

home/dot_config/ghostty/config

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ cursor-style-blink = false
2222

2323
# Mouse
2424
mouse-hide-while-typing = true
25-
copy-on-select = true
25+
# Use "clipboard" instead of "true" to copy to system clipboard on macOS (changed in 1.1.0)
26+
copy-on-select = clipboard
2627

2728
# Quick Terminal (dropdown from anywhere)
2829
# Toggle with Ctrl+` from any app
@@ -31,3 +32,20 @@ quick-terminal-position = bottom
3132
# Format: height,width (for bottom/top position)
3233
quick-terminal-size = 25%,70%
3334
quick-terminal-autohide = true
35+
36+
# Shell Integration Features
37+
# Ghostty auto-injects shell integration for supported shells (bash, zsh, fish, elvish).
38+
#
39+
# Available features:
40+
# cursor - Sets cursor to a blinking bar at the shell prompt
41+
# sudo - Wraps sudo to preserve terminfo, so terminal features work in sudo commands
42+
# title - Updates window/tab title via shell integration
43+
# no-title - Disables the title feature
44+
#
45+
# Why no-title: Starship (my prompt) overwrites PS1 entirely, which wipes out any
46+
# title escape sequences Ghostty's shell integration adds. Instead, window titles
47+
# are handled via a custom Starship module [custom.window_title] in starship.toml.
48+
# This also works around Ghostty's lack of title push/pop (CSI 22/23) support for
49+
# programs using alternate screen mode (git diff, less, vim, etc.).
50+
# See: https://github.com/ghostty-org/ghostty/discussions/2667
51+
shell-integration-features = cursor,sudo,no-title

home/dot_config/starship.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
# Palettes must be defined _after_ this line
66
palette = "catppuccin_macchiato"
77

8+
[custom.window_title]
9+
description = "Set window title to current directory (fixes title not resetting after git diff, less, etc.)"
10+
when = true
11+
command = 'printf "\\033]2;%s\\007" "$(starship module directory 2>/dev/null | sed "s/\\x1b\\[[0-9;]*m//g" | tr -d "\\n")"'
12+
format = "$output"
13+
shell = ["sh"]
14+
815
[custom.chezmoi]
916
disabled = false
1017
when = 'test -n "$CHEZMOI_EXECUTABLE"'

0 commit comments

Comments
 (0)