如中所示,可以在bash中使用read with Readline (-e)返回以前的历史项目,方法是使用上下键: history -s "$line" # append $line to local history在zsh中做这件事的正确方法是什么(在循环中获取用户输入,并允许上下键完成历史记录)。这不管用:
#!/usr/bin/env zs
我希望能够在脚本本身中记录用于运行当前python脚本的命令。例如,这是我尝试过的:import sys,subprocess for line in f.readlineslogfile','r') as f:
f.write('the command you ran: %s'%line.strip('\n'