Skip to content

Commit

Permalink
Merge pull request #8 from evverx/histtimeformat-support
Browse files Browse the repository at this point in the history
Add HISTTIMEFORMAT support
  • Loading branch information
rcaloras committed Jun 25, 2015
2 parents 7e55ac1 + 95a6b7f commit f4a78fe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bash-preexec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ __bp_preexec_invoke_exec() {
return
fi

local this_command="$(history 1 | sed -e "s/^[ ]*[0-9]*[ ]*//g")";
local this_command="$(HISTTIMEFORMAT= history 1 | sed -e "s/^[ ]*[0-9]*[ ]*//g")";

# Sanity check to make sure we have something to invoke our function with.
if [[ -z "$this_command" ]]; then
Expand Down
12 changes: 12 additions & 0 deletions test/bash-preexec.bats
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,15 @@ test_preexec_echo() {
[[ "$HISTCONTROL" == "ignoredups:::some_thing_else" ]]

}

@test "preexec should respect HISTTIMEFORMAT" {
preexec_functions+=(test_preexec_echo)
__bp_preexec_interactive_mode="on"
git_command="git commit -a -m 'commiting some stuff'"
HISTTIMEFORMAT='%F %T '
history -s $git_command

run '__bp_preexec_invoke_exec'
[[ $status == 0 ]]
[[ "$output" == "$git_command" ]]
}

0 comments on commit f4a78fe

Please sign in to comment.