Closed rebelxt closed 1 month ago
Turn off shell integration in kitty.conf and you will be fine.
Thanks for the quick response, and the accurate solution.
Since I had a few minutes, you can fix your bash code to work with shell integration as well
function timer_now {
date +%s%N
}
builtin declare -A timer_value
function timer_start {
timer_value[v]=$(timer_now)
}
function timer_stop {
local delta_us=$((($(timer_now) - ${timer_value[v]}) / 1000))
local us=$((delta_us % 1000))
local ms=$(((delta_us / 1000) % 1000))
local s=$(((delta_us / 1000000) % 60))
local m=$(((delta_us / 60000000) % 60))
local h=$((delta_us / 3600000000))
# Goal: always show around 3 digits of accuracy
if ((h > 0)); then timer_show=${h}h${m}m
elif ((m > 0)); then timer_show=${m}m${s}s
elif ((s >= 10)); then timer_show=${s}.$((ms / 100))s
elif ((s > 0)); then timer_show=${s}.$(printf %03d $ms)s
elif ((ms >= 100)); then timer_show=${ms}ms
elif ((ms > 0)); then timer_show=${ms}.$((us / 100))ms
else timer_show=${us}$'\u3bc's
fi
}
set_prompt () {
Last_Command_RC=$? # Must come first!
Blue='\[\e[1m\e[38;2;0;150;250m\]'
White='\[\e[00;97m\]'
Red='\[\e[01;31m\]'
Green='\[\e[38;2;0;255;150m\]'
Yellow='\[\e[00;93m\]'
Reset='\[\e[00m\]'
FancyX=$'\u2718'
Checkmark=$'\u2713'
Blink='\[\e[05m\]'
BlinkOff='\[\e[25m\]'
case $TERM in
'xterm-kitty')
Arrow="――►"
;;
'login')
Arrow="└─►"
;;
*)
Arrow="└─>"
;;
esac
if [[ $Last_Command_RC == 0 ]]; then
# If it was successful, print a green check mark.
PS1="$Green$Last_Command_RC $Checkmark "
else
# Otherwise, print a red X.
PS1="$Red$Last_Command_RC $Blink$FancyX$BlinkOff "
fi
# Add the elapsed time and current time
timer_stop
PS1+="$White($timer_show) $Blue\t "
# If root, just print the host in red. Otherwise, print the current user
# and host in green.
if [[ $EUID == 0 ]]; then
PS1+="$Red\\u$Green@\\h "
else
PS1+="$Yellow\\u@\\h "
fi
# Print the working directory and prompt marker in blue, and reset
# the text color to the default.
PS1+="$White\\w\n$Arrow $Red\\\$$Reset "
}
trap 'timer_start' DEBUG
PROMPT_COMMAND='set_prompt'
Very nice! Thank you.
Describe the bug Code to generate a custom terminal prompt works in a mate-terminal, but not in kitty.
To Reproduce
Screenshots bash_aliases.txt
Environment details
Additional context The problem persists with kitty --config NONE. If the unset timer_start statement is commented out or deleted, the mate-terminal shows the same results as kitty.
This is in Linux Mint 22 Mate, my daily driver. I also have a NixOS test system with the Cinnamon DE, and just realized the problem doesn't exist there. The debug information from NixOS is also attached. kc_nix.txt
Is this a bug in kitty, or does a change need to be made in the Mate config fille?