mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
profile: skip setting PS0 when PROMPT_COMMAND= is cleared
Fixes #39639.
This commit is contained in:
@@ -60,6 +60,13 @@ __systemd_osc_context_precmdline() {
|
||||
read -r systemd_osc_context_cmd_id </proc/sys/kernel/random/uuid
|
||||
}
|
||||
|
||||
__systemd_osc_context_ps0() {
|
||||
# Skip if PROMPT_COMMAND= is cleared manually or by other profiles.
|
||||
[ -n "${systemd_osc_context_cmd_id:-}" ] || return
|
||||
|
||||
printf "\033]3008;start=%s%s;type=command;cwd=%s\033\\" "$systemd_osc_context_cmd_id" "$(__systemd_osc_context_common)" "$(__systemd_osc_context_escape "$PWD")"
|
||||
}
|
||||
|
||||
if [ -n "${BASH_VERSION:-}" ]; then
|
||||
# Legacy bashrc will assign PROMPT_COMMAND=, which is equivalent to assigning
|
||||
# index 0 in the array. Leave an empty spot to handle this gracefully.
|
||||
@@ -69,5 +76,5 @@ if [ -n "${BASH_VERSION:-}" ]; then
|
||||
PROMPT_COMMAND+=(__systemd_osc_context_precmdline)
|
||||
|
||||
# PS0 is shown right after a prompt completed, but before the command is executed
|
||||
PS0='\033]3008;start=$systemd_osc_context_cmd_id$(__systemd_osc_context_common);type=command;cwd=$(__systemd_osc_context_escape "$PWD")\033\\'"${PS0:-}"
|
||||
PS0='$(__systemd_osc_context_ps0)'"${PS0:-}"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user