- 论坛徽章:
- 0
|
感觉有点意思,有空再看看。因为有点零散(主要是三人),所以改转载为抄自。
No.1
export PROMPT_COMMAND='{
date "+: %c; `history 1 | { read x cmd; echo "$cmd"; }`";
} >;>; $HOME/.history-timestamp'
或者安装 Bash 3.0
http://ftp.gnu.org/gnu/bash/bash-3.0.tar.gz
bb. New HISTTIMEFORMAT variable; value is a format string to pass to
strftime(3). If set and not null, the `history' builtin prints out
timestamp information according to the specified format when displaying
history entries. If set, bash tells the history library to write out
timestamp information when the history file is written.
或者用Snare for Linux大炮打苍蝇
No.2
试了有个楼主给的PROMPT_COMMAND,总是有问题。自己就写了个麻烦点的。
![]()
把他们加到.bashrc文件中, source .bashrc 即可。
# === Begin ====
datestamp_history(){
export infodate=`date "+: %c"`
export infohis=`history 1`
echo $infodate' =>; '$infohis >;>; $HOME/.history-timestamp
}
export PROMPT_COMMAND=datestamp_history
# === end =====
No.3
export PROMPT_COMMAND='{ z=$(history 1 | { read x y; echo $y; }); echo -n $(date "+%c") :: $z ::; who am i; } >> $HOME/.history-timestamp'
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/10295/showart_261850.html |
|