Move extraction of last cmd into its own function

This commit is contained in:
Kovid Goyal 2022-01-15 10:58:16 +05:30
parent aab121b35d
commit 5f20d69309
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -70,7 +70,11 @@ _ksi_main() {
if [[ "$HISTCONTROL" == *"ignoreboth"* ]] || [[ "$HISTCONTROL" == *"ignorespace"* ]]; then
_ksi_debug_print "ignoreboth or ignorespace present in bash HISTCONTROL setting, showing running command in window title will not be robust"
fi
_ksi_prompt[ps0]+='$(printf "\e]2;%s\a" "$(HISTTIMEFORMAT= history 1 | sed -e "s/^[ ]*[0-9]*[ ]*//")")'
_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"
}
_ksi_prompt[ps0]+='$(_ksi_get_current_command)'
fi
if [[ "${_ksi_prompt[mark]}" == "y" ]]; then