File: openTerminal.command

package info (click to toggle)
texmaker 5.1.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 80,256 kB
  • sloc: cpp: 429,691; ansic: 192,386; python: 1,935; xml: 1,724; asm: 205; sh: 176; makefile: 46
file content (29 lines) | stat: -rwxr-xr-x 933 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! /bin/bash

i=$1
i=${i//\\/\\\\\\\\}
i=${i//\"/\\\\\\\"}
i=${i//\$/\\\\\\\$}
i=${i//\`/\\\\\\\`}
i=\\\"$i\\\"
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 "cd $i"
    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