From 8174ecb31867be05e01e872326d570c278939c20 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 15 Jan 2022 11:46:25 +0530 Subject: [PATCH] Use only bash builtins to get currently executing command --- shell-integration/bash/kitty.bash | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shell-integration/bash/kitty.bash b/shell-integration/bash/kitty.bash index 81aa4648e..ecf305b2e 100644 --- a/shell-integration/bash/kitty.bash +++ b/shell-integration/bash/kitty.bash @@ -71,8 +71,10 @@ _ksi_main() { _ksi_debug_print "ignoreboth or ignorespace present in bash HISTCONTROL setting, showing running command in window title will not be robust" fi _ksi_get_current_command() { - local last_cmd=$(HISTTIMEFORMAT= builtin history 1 | command sed -e "s/^[ ]*[0-9]*[ ]*//") - builtin printf "\e]2;%s\a" "$last_cmd" + local last_cmd=$(HISTTIMEFORMAT= builtin history 1) + last_cmd="${last_cmd#*[0-9]*[[:space:]]}" # remove leading history number + last_cmd="${last_cmd#"${last_cmd%%[![:space:]]*}"}" # remove remaining leading whitespace + builtin printf "\e]2;%s\a" "${last_cmd}" } _ksi_prompt[ps0]+='$(_ksi_get_current_command)' fi