From a21e665120bf787792c367f5236378d3db27def1 Mon Sep 17 00:00:00 2001 From: Akib Azmain Turja Date: Sun, 4 Dec 2022 18:43:06 +0600 Subject: [PATCH] Use full command as title in shell integration * integration/bash (__eat_in_prompt_command): Rename to '__eat_inhibit_preexec'. * integration/bash (__eat_before_exec): Inhibit further '__eat_preexec' calls until next prompt. * integration/bash (__eat_preexec): Use 'history' to get the real command typed by the user. --- eat.el | 5 +++-- integration/bash | 14 +++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/eat.el b/eat.el index 7b1f4cd..1f937ea 100644 --- a/eat.el +++ b/eat.el @@ -249,8 +249,9 @@ This value is used by terminal programs to identify the terminal." (function :tag "Function")) :group 'eat-term) -;; Upgrading Eat causes `eat-term-terminfo-directory' to be outdated, -;; so update it if not modified by user (or something else). +;; Upgrading Eat causes `eat-term-terminfo-directory' and +;; `eat-term-shell-integration-directory' to be outdated, so update it +;; if not modified by user (or something else). (defvar eat--install-path nil "Path to directory where Eat is installed.") diff --git a/integration/bash b/integration/bash index dcc639a..1c2a5c3 100644 --- a/integration/bash +++ b/integration/bash @@ -25,27 +25,31 @@ __eat_prompt_command () { __eat_preexec () { # "${PWD/$HOME/'~'}" converts "/home/akib/org/" to "~/org/". # The next one is substituted with '$', or '#' if we're "root". + # The final one gets the real command typed by the user from the + # history. printf '\e]2;%s@%s:%s%s %s\e\\' "$USER" "$HOSTNAME" \ "${PWD/$HOME/'~'}" \ - "$(test $UID -eq 0 && echo '#' || echo '$')" "$BASH_COMMAND" + "$(test $UID -eq 0 && echo '#' || echo '$')" \ + "$(history 1 | sed 's/ *[0-9]* *//')" } -__eat_in_prompt_command=no +__eat_inhibit_preexec=yes __eat_before_prompt_command () { - __eat_in_prompt_command=yes + __eat_inhibit_preexec=yes } __eat_after_prompt_command () { - __eat_in_prompt_command=no + __eat_inhibit_preexec=no } __eat_before_exec () { - if test $__eat_in_prompt_command = no \ + if test $__eat_inhibit_preexec = no \ && test "$BASH_COMMAND" != __eat_before_prompt_command then + __eat_inhibit_preexec=yes __eat_preexec fi }