unset HISTTIMEFORMAT before calling history in bash scripts
The bash integration script calls \history
(which alternatively should be builtin history
). My environment has HISTTIMEFORMAT
set which outputs a strftime
formatted timestamp between the history number and the command. Unsetting the variable before calling history will remove it.
diff --git a/bash_startup.in b/bash_startup.in
index b19825d..2bc5ca8 100644
--- a/bash_startup.in
+++ b/bash_startup.in
@@ -57,7 +57,7 @@ if ( [ x"$TERM" != xscreen ] ); then
shopt -s extdebug > /dev/null 2>&1
local s=$?
- last_hist_ent="$(\history 1)";
+ last_hist_ent="$(HISTTIMEFORMAT= builtin history 1)";
precmd;
# This is an iTerm2 addition to try to work around a problem in the
# original preexec.bash.
@@ -152,7 +152,7 @@ if ( [ x"$TERM" != xscreen ] ); then
# variable, but using history here is better in some ways: for example, "ps
# auxf | less" will show up with both sides of the pipe if we use history,
# but only as "ps auxf" if not.
- hist_ent="$(\history 1)";
+ hist_ent="$(HISTTIMEFORMAT= builtin history 1)";
local prev_hist_ent="${last_hist_ent}";
last_hist_ent="${hist_ent}";
if [[ "${prev_hist_ent}" != "${hist_ent}" ]]; then