Qt Creator y iTerm2

0

Qt Creator abre la aplicación UGLY Terminal para ejecutar / depurar programas. Utilizando este script:

#! /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 "$@" ; do
    x=$(printf '%q ' "$a")
    x="${x//\/\\}"
    args[${#args[@]}]="${x//\"/\\"}"
done
mArgs=${args[@]:0}

osascript <<EOF
    --Terminal opens a window by default when it is not running, so check
    on applicationIsRunning(applicationName)
            tell application "System Events" to count (every process whose name is applicationName)
            return result is greater than 0
    end applicationIsRunning
    set terminalWasRunning to applicationIsRunning("Terminal")

    set cdScript to "$mArgs"
    tell application "Terminal"
        --do script will open a new window if none given, but terminal already opens one if not running
        if terminalWasRunning then
            do script cdScript
        else
            do script cdScript in first window
        end if
        set currentTab to the result
        set currentWindow to first window whose tabs contains currentTab
        activate
    end tell
EOF

¿Cómo puedo obligarlo a usar iTerm2 en lugar de Terminal ...?

    
pregunta mohammadreza 14.12.2016 - 05:08

1 respuesta

1

El script que has publicado es una base bastante buena para algunas ediciones. La segunda parte es AppleScript, y iTerm2 ofrece una interfaz agradable con él.

Primero, cree un script (digamos ~/newiTerm.sh ) y coloque el siguiente contenido

#! /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 "$@" ; 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

Luego, vaya a Preferencias Qt ( ⌘, ) > Medio ambiente > Sistema > Terminal y establece el valor en ~/newiTerm.sh

Funciona bien para mí.

Saludos

    
respondido por el Alexandre Germain 23.06.2017 - 01:40

Lea otras preguntas en las etiquetas