Skip to content

Commit bdfb987

Browse files
committed
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.
1 parent 9ce199c commit bdfb987

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

plugins/available/xterm.plugin.bash

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ precmd_xterm_title() {
3030
}
3131

3232
preexec_xterm_title() {
33-
set_xterm_title "$(_short-command "${1:-}") {$(_short-dirname)} (${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}})"
33+
local command_line="${BASH_COMMAND:-${1:-}}"
34+
local directory_name short_command
35+
directory_name="$(_short-dirname)"
36+
short_command="$(_short-command "${command_line}")"
37+
set_xterm_title "${short_command} {${directory_name}} (${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}})"
3438
}
3539

3640
case "${TERM:-dumb}" in

0 commit comments

Comments
 (0)