profile/systemd-osc-context: fold emitting cwd= field into __systemd_osc_context_common

Now that the %s specifier used to embed the common fields in the output appears
immediately before the cwd= field, we can just emit that cwd= field as part of
the common fields.
This commit is contained in:
Rasmus Villemoes
2026-07-21 11:06:30 +02:00
parent ac4c3e4290
commit ccace17d2f
+3 -2
View File
@@ -53,6 +53,7 @@ __systemd_osc_context_common() {
printf ";machineid=%.36s" "$(</etc/machine-id)" printf ";machineid=%.36s" "$(</etc/machine-id)"
fi fi
printf ";user=%.255s;hostname=%.255s;bootid=%.36s;pid=%.20s" "$USER" "$HOSTNAME" "$(</proc/sys/kernel/random/boot_id)" "$$" printf ";user=%.255s;hostname=%.255s;bootid=%.36s;pid=%.20s" "$USER" "$HOSTNAME" "$(</proc/sys/kernel/random/boot_id)" "$$"
printf ";cwd=%.255s" "$(__systemd_osc_context_escape "$PWD")"
} }
__systemd_osc_context_precmdline() { __systemd_osc_context_precmdline() {
@@ -75,7 +76,7 @@ __systemd_osc_context_precmdline() {
fi fi
# Create or update the shell session # Create or update the shell session
printf "\033]3008;start=%.64s;type=shell%s;cwd=%.255s\033\\" "$systemd_osc_context_shell_id" "$(__systemd_osc_context_common)" "$(__systemd_osc_context_escape "$PWD")" printf "\033]3008;start=%.64s;type=shell%s\033\\" "$systemd_osc_context_shell_id" "$(__systemd_osc_context_common)"
# Prepare cmd id for next command # Prepare cmd id for next command
read -r systemd_osc_context_cmd_id </proc/sys/kernel/random/uuid read -r systemd_osc_context_cmd_id </proc/sys/kernel/random/uuid
@@ -85,7 +86,7 @@ __systemd_osc_context_ps0() {
# Skip if PROMPT_COMMAND= is cleared manually or by other profiles. # Skip if PROMPT_COMMAND= is cleared manually or by other profiles.
[ -n "${systemd_osc_context_cmd_id:-}" ] || return [ -n "${systemd_osc_context_cmd_id:-}" ] || return
printf "\033]3008;start=%.64s;type=command%s;cwd=%.255s\033\\" "$systemd_osc_context_cmd_id" "$(__systemd_osc_context_common)" "$(__systemd_osc_context_escape "$PWD")" printf "\033]3008;start=%.64s;type=command%s\033\\" "$systemd_osc_context_cmd_id" "$(__systemd_osc_context_common)"
} }
if [ -n "${BASH_VERSION:-}" ]; then if [ -n "${BASH_VERSION:-}" ]; then