From bdfb987f0c6cb4fcbdd34652eca5564f1c03a5a8 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Wed, 20 Oct 2021 15:50:15 -0400 Subject: [PATCH] plugin/xterm: don't rely on `$1` _bash-preexec_ passes the "current" command line as `$1`, but this is unreliable and we explicitly discourage it's use. Use `$BASH_COMMAND` instead. --- plugins/available/xterm.plugin.bash | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/available/xterm.plugin.bash b/plugins/available/xterm.plugin.bash index b8747a25..740460e4 100644 --- a/plugins/available/xterm.plugin.bash +++ b/plugins/available/xterm.plugin.bash @@ -30,7 +30,11 @@ precmd_xterm_title() { } preexec_xterm_title() { - set_xterm_title "$(_short-command "${1:-}") {$(_short-dirname)} (${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}})" + local command_line="${BASH_COMMAND:-${1:-}}" + local directory_name short_command + directory_name="$(_short-dirname)" + short_command="$(_short-command "${command_line}")" + set_xterm_title "${short_command} {${directory_name}} (${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}})" } case "${TERM:-dumb}" in