Fixes for the OSC prompt script (#39588)
This commit is contained in:
@@ -13,6 +13,10 @@
|
||||
# Not bash?
|
||||
[ -n "${BASH_VERSION:-}" ] || return 0
|
||||
|
||||
# If we're on a "dumb" terminal, do not install the prompt.
|
||||
# Treat missing $TERM same as "dumb".
|
||||
[ "${TERM:-dumb}" = "dumb" ] && return 0
|
||||
|
||||
__systemd_osc_context_escape() {
|
||||
# Escape according to the OSC 3008 spec. Since this requires shelling out
|
||||
# to 'sed' we'll only do it where it's strictly necessary, and skip it when
|
||||
@@ -56,8 +60,12 @@ __systemd_osc_context_precmdline() {
|
||||
read -r systemd_osc_context_cmd_id </proc/sys/kernel/random/uuid
|
||||
}
|
||||
|
||||
if [[ -n "${BASH_VERSION:-}" ]] && [[ "${TERM:-}" != "dumb" ]]; then
|
||||
# Whenever a new prompt is shown close the previous command, and prepare new command
|
||||
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.
|
||||
[ -n "$(declare -p PROMPT_COMMAND 2>/dev/null)" ] || PROMPT_COMMAND+=('')
|
||||
|
||||
# Whenever a new prompt is shown, close the previous command, and prepare new command
|
||||
PROMPT_COMMAND+=(__systemd_osc_context_precmdline)
|
||||
|
||||
# PS0 is shown right after a prompt completed, but before the command is executed
|
||||
|
||||
Reference in New Issue
Block a user