2013-05-27 44 views
1

我想使用Platypus为OSX 10.8上的交互式命令行程序创建应用程序启动器。我希望能够双击我的应用程序,并打开终端窗口,运行我的程序。问题是我的Applescript(从Octave借来的,适应于Julia)启动了一个终端窗口,并试图向它吐出一些命令,但是我有一个相当大的干扰这个的~/.bash_profile。有没有办法让我的Applescript打开一个非登录shell,或者不是源码~/.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 

回答

0

一般情况下,你不需要一个终端窗口,执行命令行的东西。如果您需要手动输入信息,则只能使用终端。因此,您可以在终端窗口中使用“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的个人资料将不会被使用。

+0

我的命令行程序是交互式的。实际上,它是一个REPL,因此在没有终端窗口的情况下运行它将不起作用。 – staticfloat