shell-integration: implement "no-cursor" option

Implement a "no-cursor" option for shell integration. This option acts
like "detect" but doesn't set the cursor shape.
This commit is contained in:
Tim Culverhouse
2023-11-07 16:24:58 -06:00
parent 36dd5ef4ee
commit 4fac674016
5 changed files with 44 additions and 23 deletions

View File

@@ -200,21 +200,23 @@ _ghostty_deferred_init() {
functions[_ghostty_preexec]+="
builtin print -rnu $_ghostty_fd \$'\\e]2;'\"\${(V)1}\"\$'\\a'"
# Enable cursor shape changes depending on the current keymap.
# This implementation leaks blinking block cursor into external commands
# executed from zle. For example, users of fzf-based widgets may find
# themselves with a blinking block cursor within fzf.
_ghostty_zle_line_init _ghostty_zle_line_finish _ghostty_zle_keymap_select() {
case ${KEYMAP-} in
# Blinking block cursor.
vicmd|visual) builtin print -nu "$_ghostty_fd" '\e[1 q';;
# Blinking bar cursor.
*) builtin print -nu "$_ghostty_fd" '\e[5 q';;
esac
}
# Restore the blinking default shape before executing an external command
functions[_ghostty_preexec]+="
builtin print -rnu $_ghostty_fd \$'\\e[0 q'"
if [[ "$GHOSTTY_SHELL_INTEGRATION_NO_CURSOR" != 1 ]]; then
# Enable cursor shape changes depending on the current keymap.
# This implementation leaks blinking block cursor into external commands
# executed from zle. For example, users of fzf-based widgets may find
# themselves with a blinking block cursor within fzf.
_ghostty_zle_line_init _ghostty_zle_line_finish _ghostty_zle_keymap_select() {
case ${KEYMAP-} in
# Blinking block cursor.
vicmd|visual) builtin print -nu "$_ghostty_fd" '\e[1 q';;
# Blinking bar cursor.
*) builtin print -nu "$_ghostty_fd" '\e[5 q';;
esac
}
# Restore the blinking default shape before executing an external command
functions[_ghostty_preexec]+="
builtin print -rnu $_ghostty_fd \$'\\e[0 q'"
fi
# Some zsh users manually run `source ~/.zshrc` in order to apply rc file
# changes to the current shell. This is a terrible practice that breaks many