[英]Applescript to open Terminal window without sourcing ~/.bash_profile
我正在嘗試使用Platypus在OSX 10.8上為交互式命令行程序創建應用程序啟動器。 我希望能夠雙擊我的應用程序,並打開一個運行我的程序的終端窗口。 問題是我的Applescript(從Octave借來的,並且適合Julia )啟動了一個Terminal窗口,並嘗試向其中吐出一些命令,但是我的~/.bash_profile
,妨礙了它。 有沒有辦法讓我的Applescript打開非登錄外殼,或者沒有源~/.bash_profile
等?
這是鴨嘴獸運行的腳本:
# This is the startup procedure written as AppleScript to open a
# Terminal.app (if the Terminal.app is not already running) and start
# the Julia program.
# 20071007 removed: open -a /Applications/Utilities/Terminal.app
osascript 2>&1>/dev/null <<EOF
tell application "System Events" to set ProcessList to get name of every process
tell application "Terminal"
activate
if (ProcessList contains "Terminal") or ((count of every window) is less than 1) then
tell application "System Events" to tell process "Terminal" to keystroke "n" using command down
end if
do script ("exec bash -c \"PATH=${ROOT}/julia/bin:${PATH} OPENBLAS_NUM_THREADS=1 FONTCONFIG_PATH=${ROOT}/julia/etc/fonts GIT_EXEC_PATH=${ROOT}/julia/libexec/git-core GIT_TEMPLATE_DIR=${ROOT}/julia/share/git-core exec '${ROOT}/julia/bin/julia'\"") in front window
end tell
EOF
# Quit the Julia.application immediately after startup (ie. quitting
# it in the taskbar) because once it is started it cannot be restarted
# a second time. If Julia.app stays (eg. because of a crash) opened
# then restarting is not possible.
osascript 2>&1>/dev/null <<EOF
tell application "julia"
quit
end tell
EOF
通常,您不需要終端窗口即可執行命令行內容。 僅當需要手動輸入信息時,才使用終端。 因此,您可以只在終端窗口中使用“ do shell script”而不是“ do script”運行命令。 請注意,以這種方式進行操作不會使用您的bash配置文件。 因此,請在applescript中單獨嘗試執行此命令...
do shell script ("exec bash -c \"PATH=${ROOT}/julia/bin:${PATH} OPENBLAS_NUM_THREADS=1 FONTCONFIG_PATH=${ROOT}/julia/etc/fonts GIT_EXEC_PATH=${ROOT}/julia/libexec/git-core GIT_TEMPLATE_DIR=${ROOT}/julia/share/git-core exec '${ROOT}/julia/bin/julia'\"")
然后,您可以根據需要添加其他applescript命令,只是不要使用終端,因此不會使用您的bash配置文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.