特定のディレクトリに cd して pwd を開くコマンドを実行できるように、bash エイリアスの作成に取り組んでいます。私のスクリプトはうまく機能しますが、${pwd} を取得すると、bash_profile ファイルの pwd が取得されます。呼び出し元の端末ウィンドウの pwd を取得するにはどうすればよいですか?
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"'
私は周りの引用符を変更しなければなりませんでした..また、そこに二重引用符を保持する必要があったようです。
私が書いたもう 1 つの楽しい Coda bash スクリプト:
現在のディレクトリから特定のファイルを開きます。
function coda() { osascript -e "tell application \"Coda\"" -e "tell document 1" -e "open \"${PWD}/$@\"" -e "end tell" -e "end tell";}
例) coda myfile.txt