File: grass-xterm-mac

package info (click to toggle)
grass 8.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 277,040 kB
  • sloc: ansic: 460,798; python: 227,732; cpp: 42,026; sh: 11,262; makefile: 7,007; xml: 3,637; sql: 968; lex: 520; javascript: 484; yacc: 450; asm: 387; perl: 157; sed: 25; objc: 6; ruby: 4
file content (72 lines) | stat: -rwxr-xr-x 1,838 bytes parent folder | download | duplicates (2)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh
# script to emulate an xterm in OSX Terminal.app
#
# -William Kyngesburye

# just in case accidentally called on another system
SYSTEMOSX=`uname -s | grep "Darwin"`

if [ "$SYSTEMOSX" ] ; then
    # manually transfer the necessary env vars
    TMPSCRIPT="/tmp/grassxterm_$$"
    (
	cat <<-EOF
	#!/bin/sh
	DISPLAY="$DISPLAY"
	PATH="$PATH"
	GIS_LOCK="$GIS_LOCK"
	GISRC="$GISRC"
	GISBASE="$GISBASE"
	GRASS_VERSION="$GRASS_VERSION"
	GRASS_PAGER="$GRASS_PAGER"
	DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH"
	GRASS_HTML_BROWSER="$GRASS_HTML_BROWSER"
	GRASS_HTML_BROWSER_MACOSX="$GRASS_HTML_BROWSER_MACOSX"
	export DISPLAY PATH GIS_LOCK GISRC GISBASE GRASS_VERSION GRASS_PAGER DYLD_LIBRARY_PATH GRASS_LD_LIBRARY_PATH GRASS_HTML_BROWSER GRASS_HTML_BROWSER_MACOSX
	EOF

	if [ "$GRASS_ADDON_PATH" ] ; then
	    echo "GRASS_ADDON_PATH=\"$GRASS_ADDON_PATH\""
	    echo "export GRASS_ADDON_PATH"
	fi

	if [ -z "$MANPATH" ] ; then
	    echo "MANPATH=\"$GISBASE/docs/man:`manpath`\""
	else
	    echo "MANPATH=\"$GISBASE/docs/man:$MANPATH\""
	fi
	echo "export MANPATH"

	# get command, ignore all other xterm flags
	while true ; do
	    if [ "$1" = "-e" ] ; then break ; fi
	    shift
	done
	shift
	# and add it to end of script
	echo "$@"
    ) > "$TMPSCRIPT.sh"
    chmod +x "$TMPSCRIPT.sh"

    # execute
    # save current active app/window, return to it when script finishes.
    osascript - <<EOF
--tell application "System Events"
--	set save_app to item 1 of (get name of processes whose frontmost is true)
--end tell
tell application "Terminal"
	activate
	-- start new window with env/cmd script
	do script "$TMPSCRIPT.sh; exit"
	tell window 1
		-- wait for it to finish
		repeat while (processes is not equal to {})
			delay 1
		end repeat
		close
	end tell
end tell
--tell application save_app to activate
EOF
    rm -f "$TMPSCRIPT.sh"
fi