
代码: 全选
cd .zsh_history$HOME
代码: 全选
#使用 histall 命令查看全部历史纪录
function allhistory { cat $(find $HOME/.zsh_history -name zhistory) | sort }
function convhistory {
awk -F"[:;]" '{
print "[" strftime("%Y-%m-%d %T",$2) "]" , $4
}' $1
}
function histall { convhistory =(allhistory) }
#全部历史纪录 top15
function top15 { cat =(allhistory) | awk -F':[ 0-9]*:[0-9]*;' '{ print $1 , $2 }' | sort | uniq -c | sort -nr | head -n 15 }
kardinal 写了: 原来的版本,如果命令中出现多个分隔符 ":" 或 ";"
分隔符后面的部分不能显示。
代码: 全选
function allhistory { cat $(find $HOME/.zsh_history -name zhistory) }
function convhistory {
sort $1 | uniq |
sed 's/^:\([ 0-9]*\):[0-9]*;\(.*\)/\1::::::\2/' |
awk -F"::::::" '{ $1=strftime("%Y-%m-%d %T",$1) "|"; print }'
}
#使用 histall 命令查看全部历史纪录
function histall { convhistory =(allhistory) |
sed '/^.\{20\} *cd/i\\' }
#使用 hist 查看当前目录历史纪录
function hist { convhistory $HISTFILE }
代码: 全选
2009-03-02 11:32:31| ls ; ls ;ls
2009-03-02 11:33:12| ls ; du
2009-03-02 11:33:16| du ; ls
2009-03-02 11:33:22| ls ;ls ;du ;du
代码: 全选
#全部历史纪录关键字 top44
function top44 { allhistory | awk -F':[ 0-9]*:[0-9]*;' '{ $1="" ; print }' | sed 's/ /\n/g' | sed '/^$/d' | sort | uniq -c | sort -nr | head -n 44 }
代码: 全选
user-complete(){
case $BUFFER in
"cd --" ) # "cd --" 替换为 "cd +"
BUFFER="cd +"
zle end-of-line
zle expand-or-complete
;;
"cd +-" ) # "cd +-" 替换为 "cd -"
BUFFER="cd -"
zle end-of-line
zle expand-or-complete
;;
"" ) # 空行填入 "cd "
BUFFER="cd "
zle end-of-line
zle expand-or-complete
;;
* )
zle expand-or-complete
;;
esac
}
kardinal 写了:这个俺不能认同。举几个例子eexpress 写了:shell熟悉了都好用啊。
ls > a > b > c > d > e
这样的多重重定向,整个 bash 版的瞅瞅
当然,这种用法不实用,但是 zsh 里面管道重定向之类的组合很 BT
$() 这个也比 bash 里的 `` 好用多了
上面的返回内容, =() 返回文件名
比如
diff =(ls a/) =(ls b/) 比较 a b 两个文件夹的文件列表
用 bash 可以么?这些可都是不用任何设置就有的功能哦
感觉这个还是比较难的,起码不直观......wen1987 写了:多重定向功能一点也不难,比如
echo abc | tee file1 file2 > file3
或者
echo abc | tee > >(foo1) > >(foo2) | foo3