Answers:
我相信HISTTIMEFORMAT适用于Bash shell。如果您正在使用,zsh则可以对history命令使用以下开关:
$ history -E
1 2.12.2013 14:19 history -E
$ history -i
1 2013-12-02 14:19 history -E
$ history -D
1 0:00 history -E
2 0:00 history -i
如果你做一个 man zshoptions或man zshbuiltins,则可以找到有关这些开关的更多信息以及与相关的其他信息history。
zshbuiltins手册页摘录
Also when listing,
-d prints timestamps for each command
-f prints full time-date stamps in the US `MM/DD/YY hh:mm' format
-E prints full time-date stamps in the European `dd.mm.yyyy hh:mm' format
-i prints full time-date stamps in ISO8601 `yyyy-mm-dd hh:mm' format
-t fmt prints time and date stamps in the given format; fmt is formatted
with the strftime function with the zsh extensions described for
the %D{string} prompt format in the section EXPANSION OF PROMPT
SEQUENCES in zshmisc(1). The resulting formatted string must be no
more than 256 characters or will not be printed.
-D prints elapsed times; may be combined with one of the options above.
您可以使用以下2种方法进行调试 zsh调用它时,。
方法1
$ zsh -xv
方法#2
$ zsh
$ setopt XTRACE VERBOSE
无论哪种情况,启动时您都应该看到类似以下内容:
$ zsh -xv
#
# /etc/zshenv is sourced on all invocations of the
# shell, unless the -f option is set. It should
# contain commands to set the command search path,
# plus other important environment variables.
# .zshenv should not contain commands that produce
# output or assume the shell is attached to a tty.
#
#
# /etc/zshrc is sourced in interactive shells. It
# should contain commands to set up aliases, functions,
# options, key bindings, etc.
#
## shell functions
...
...
unset -f pathmunge _src_etc_profile_d
+/etc/zshrc:49> unset -f pathmunge _src_etc_profile_d
# Created by newuser for 4.3.10
zsh?zsh --version。我刚刚在Ubuntu 12.10上确认,我给您的命令工作正常。
zshbuiltins手册页后,我发现需要使用fc。最终对我有用的是fc -li。您也可以将命令号传递给fc,因此fc -li -100列出了历史记录中的最后100条命令。
\history -E,我使用oh-my-zsh
history -E或history -i或任何不要为我工作。
zsh --version表明zsh 4.3.6 (x86_64-suse-linux-gnu)。
然后fc -li 100工作!它显示带有时间戳的最近100条命令:)
zsh 5.1.1 (x86_64-ubuntu-linux-gnu)。当我在这里时:您知道如何获得命令的帮助fc吗?既不工作man fc也不fc --help做工
oh-my-zsh是history命令,则-l在选项之一中添加标志。看到github.com/robbyrussell/oh-my-zsh/blob/master/lib/...
fc -lf将显示完整的时间戳。请注意,这仅适用于zsh,不适用于bash。
run-help fc。
如果您在中使用oh-my-zsh插件zsh,history -E否则将history -i无法工作(因为它的别名为fc -l 1)。
正如@juanpastas指出的那样,尝试
\history -E
要么
\history -i
要么
fc -li 100