Joh*_*ino 67 command-history zsh
当我在 ubuntu 服务器上运行 history 命令时,我得到如下输出:
history
...
25 cd ~
26 ls -a
27 vim /etc/gitconfig
28 vim ~/.gitconfig
Run Code Online (Sandbox Code Playgroud)
我想查看特定用户的日期时间。但是,当我假设它们时:
su otheruser
export HISTTIMEFORMAT='%F %T '
history
...
25 cd ~
26 ls -a
27 vim /etc/gitconfig
28 vim ~/.gitconfig
Run Code Online (Sandbox Code Playgroud)
它仍然不显示日期时间。我正在使用 zsh shell。
slm*_*slm 98
我相信 HISTTIMEFORMAT 适用于 Bash shell。如果您正在使用,zsh
那么您可以将这些开关用于history
命令:
$ history -E
1 2.12.2013 14:19 history -E
Run Code Online (Sandbox Code Playgroud)
或者:\history -E
$ history -i
1 2013-12-02 14:19 history -E
Run Code Online (Sandbox Code Playgroud)
或者:\history -i
$ history -D
1 0:00 history -E
2 0:00 history -i
Run Code Online (Sandbox Code Playgroud)
如果您执行 aman 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.
Run Code Online (Sandbox Code Playgroud)
zsh
调用时可以使用以下2种方法进行调试。
方法#1
$ zsh -xv
Run Code Online (Sandbox Code Playgroud)
方法#2
$ zsh
$ setopt XTRACE VERBOSE
Run Code Online (Sandbox Code Playgroud)
无论哪种情况,您都应该在启动时看到如下内容:
$ 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
Run Code Online (Sandbox Code Playgroud)
Gab*_*是好人 24
history -E
或history -i
或任何不要为我工作。
zsh --version
表明zsh 4.3.6 (x86_64-suse-linux-gnu)
.
然后fc -li 100
工作!它显示了最近的 100 个带有时间戳的命令:)
如果您在 中使用oh-my-zsh
插件zsh
,history -E
或者history -i
无法使用(因为它的别名为fc -l 1
)。
正如@juanpastas 指出的,尝试
\history -E
或者
\history -i
或者
fc -li 100