我正在创建一个 bash 别名,这样我就可以 cd 到给定的目录并运行一个打开 pwd 的命令。我的脚本运行良好,但是当我抓取 ${pwd} 时,它会抓取 bash_profile 文件的密码。如何获取调用终端窗口的密码?
alias opencoda="osascript -e 'tell application \"Coda\"' -e 'tell document 1' -e 'change local path \"${pwd}\"' -e 'end tell' -e 'end tell'"
解决方案我不确定为什么上面给出了 bash_profile 目录,而这个给出了终端目录,但尽管如此:
alias opencoda='osascript -e "tell application \"Coda\"" -e "tell document 1" -e "change local path \"${PWD}\"" -e "end tell" -e "end tell"'
我不得不改变引号..显然还需要在里面保留双引号。
我刚刚写的另一个有趣的 Coda bash 脚本:
从当前目录打开给定文件:
function coda() { osascript -e "tell application \"Coda\"" -e "tell document 1" -e "open \"${PWD}/$@\"" -e "end tell" -e "end tell";}
例如)结尾 myfile.txt