Tools: permit overriding shell to use when running in terminal window

This commit is contained in:
Peter Barker 2017-01-11 16:02:05 +11:00
parent 7c7144fd8f
commit 1432763ca5

View File

@ -6,8 +6,25 @@
name="$1" name="$1"
shift shift
echo "RiTW: Starting $name : $*" echo "RiTW: Starting $name : $*"
# default to xterm as it has the most consistent options and can start minimised
if [ -n "$DISPLAY" -a -n "$(which osascript)" ]; then if [ -n "$SITL_RITW_TERMINAL" ]; then
# create a small shell script containing the command to run; this
# avoids problems where "screen" expects arguments in
# argv[1],argv[2],argv[3] where gnome-terminal expects the command
# to run be in argv[n+1] where argv[n] is "-e"
# this should work with:
# export SITL_RITW_TERMINAL="screen -D -m"
# export SITL_RITW_TERMINAL="gnome-terminal -e"
# export SITL_RITW_TERMINAL="konsole -e"
test -z "$TMPDIR" && TMPDIR="/tmp/"
FILENAME="ritw-`date '+%Y%m%d%H%M%S'`"
FILEPATH="$TMPDIR/$FILENAME"
echo "#!/bin/sh" >"$FILEPATH"
echo "$*" >>"$FILEPATH"
chmod +x "$FILEPATH"
$SITL_RITW_TERMINAL "$FILEPATH" &
elif [ -n "$DISPLAY" -a -n "$(which osascript)" ]; then
osascript -e 'tell application "Terminal" to do script "'"$* "'"' osascript -e 'tell application "Terminal" to do script "'"$* "'"'
elif [ -n "$DISPLAY" -a -n "$(which xterm)" ]; then elif [ -n "$DISPLAY" -a -n "$(which xterm)" ]; then
xterm -iconic -xrm 'XTerm*selectToClipboard: true' -xrm 'XTerm*initialFont: 6' -n "$name" -name "$name" -T "$name" -hold -e $* & xterm -iconic -xrm 'XTerm*selectToClipboard: true' -xrm 'XTerm*initialFont: 6' -n "$name" -name "$name" -T "$name" -hold -e $* &