2013-03-29 103 views
1

这是一个zsh特定脚本,稍后我会担心bash(即从不)。zsh - 从shell脚本中获取命令历史记录

这是我到目前为止。

#!/home/slu/.zsh/bin/zsh 

# This is a shellscript generator that converts a history entry to a script 
set -e 

if [[ $2 =~ [0-9]+ ]] 
then 
    cmd= !$2 
    echo "first arg is $1 and command is $cmd" 
else 
    echo "Invalid 2nd arg" 
    exit 1 
fi 

这显然是行不通的,因为它看起来该命令!33当我通过它33作为第二ARG。

换句话说, bash的history -p的等效zsh是什么?

如何让脚本扩展它?

回答

0

我相信答案是fc -l $2 $2

完整的脚本保持更新here

相关问题