2017-06-15 233 views
2

如何将iterm2设置为Qt Creator中的终端?当我点击“在这里打开终端”时,它会打开Mac OS默认终端。我怎样才能改变它打开例如iterm2取而代之?如何更换Qt Creator中的终端?

open terminal here

+1

这实际上是一个体面的问题! “环境/系统/终端”设置存在于“首选项”对话框中,但不允许自由格式输入。我将不得不检查Qt Creator如何选择终端来填充此列表。 –

+1

Qt Creator 4.1(Ubuntu)允许将'Environment/System/Terminal'更改为任何值。 – m7913d

回答

2

看到你是在OSX上,你可以使用该解决方案我posted here。您可以创建一个新脚本来打开一个新的iTerm2窗口,然后执行命令/脚本。

对于舒适,这里是我的答案的副本:


首先,创建一个脚本(假设~/newiTerm.sh),并把下面的内容

#! /bin/bash 

# ugly escaping: for apple script \ and " need to be escaped, whereas %q takes care of all bash escaping 

declare -a args 
mydir=`pwd` 
mydir=$(printf '%q' "$mydir") 
mydir="${mydir//\\/\\\\}" 
args[0]="cd ${mydir//\"/\\\"};" 
for a in "[email protected]" ; do 
    x=$(printf '%q ' "$a") 
    x="${x//\\/\\\\}" 
    args[${#args[@]}]="${x//\"/\\\"}" 
done 
mArgs=${args[@]:0} 

osascript <<EOF 
set cdScript to "$mArgs" 
tell application "iTerm2" 
    set newWindow to (create window with default profile) 
    tell newWindow 
     select 
     set _session to current session 
     tell _session 
      write text cdScript 
     end tell 
    end tell 
end tell 

然后,转到Qt首选项⌘,)>环境>系统>终端和值设置为~/newiTerm.sh

干杯

- 请确保您有shell脚本的权限。 你需要给予适当的许可,像这样chmod a+x ~/newiTerm.sh。否则,QT将无法运行它。

Sceenshot of setting window

+0

我需要改变的地方。我无法看到'环境>终端'选项 –

+1

对不起,它是在**系统**选项卡 –

+0

谢谢@亚历山大·杰曼 - 伟大的脚本:) –