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.
This commit is contained in:
John D Pell
2021-10-20 15:50:15 -04:00
parent 9ce199c251
commit bdfb987f0c

View File

@@ -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