有没有办法在执行任何终端命令之前运行一个命令?
例如:
> ls -ltr
> "Hello you ran ls -ltr" //this is what I would like to achieve
> ..output of ls -ltr will be here
Run Code Online (Sandbox Code Playgroud)
是否可以在执行任何命令之前运行以确保 echo 运行?
谢谢
您可能想考虑设置一个DEBUG
陷阱,它允许您以类似于zsh
. 请参阅https://superuser.com/questions/175799/does-bash-have-a-hook-that-is-run-before-executing-a-command。