summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2002-03-10 08:24:55 +0000
committerJonas Smedegaard <dr@jones.dk>2002-03-10 08:24:55 +0000
commit4fb53e4645bb1d6103b90f4c91b7826867b30d9c (patch)
tree36a7c481f121c35841e9ab09ca0a3d05228c8837
parent2efc6bc6e6c3ddc1a83399e8d71913c73bded873 (diff)
Optimize xsh terminal handling and local/remote options, and use the script - correctly - with xmc and xpine.
-rwxr-xr-xxmc8
-rwxr-xr-xxpine8
-rwxr-xr-xxsh83
3 files changed, 49 insertions, 50 deletions
diff --git a/xmc b/xmc
index 12772f2..1fa1e54 100755
--- a/xmc
+++ b/xmc
@@ -1,9 +1,9 @@
#!/bin/bash
if [ $# -eq 0 ]; then
- host="localhost"
+ xsh localhost mc
+elif [ $# -eq 1 -a "$1" = "su" ]; then
+ xsh localhost mc su
else
- host="$1"
+ xsh $@ mc
fi
-shift
-xsh $host mc $@
diff --git a/xpine b/xpine
index afa8314..5f8eede 100755
--- a/xpine
+++ b/xpine
@@ -1,4 +1,10 @@
#!/bin/sh
-rxvt +sb -sl 500 -n "Pine" -title "Pine" -e pine &
+#rxvt +sb -sl 500 -n "Pine" -title "Pine" -e pine &
#exec rxvt +sb -sl 500 -n "Pine" -title "Pine" -e pine
+
+if [ $# -eq 0 ]; then
+ xsh localhost pine
+else
+ xsh $@ pine
+fi
diff --git a/xsh b/xsh
index b79209f..1e66121 100755
--- a/xsh
+++ b/xsh
@@ -8,25 +8,27 @@ function usage () {
function termwrapper () {
PRG=$@
- title="$title $titleopt"
+ titletext="$title $titleopt"
[ "$V" = 1 ] && echo $PRG
-# case `readlink /etc/alternatives/x-terminal-emulator | xargs basename` in
-# rxvt*)
-# opts="+sb -sl 500 -n \"$title\" -title \"$title\""
-# ;;
-# esac
+ case `readlink /etc/alternatives/x-terminal-emulator | xargs basename` in
+# rxvt*) opts="+sb -sl 500 -n \"$titletext\""; titleoptname="-title";;
+ rxvt*) opts="+sb -sl 500"; titleoptname="-title";;
+ *xterm) opts="+sb -sl 500 +wc"; titleoptname="-title";;
+ gnome-terminal) opts=""; titleoptname="--title";;
+ gnome-terminal.wrapper) opts=""; titleoptname="-title";;
+ konsole*) opts="--notoolbar"; titleoptname="-T";;
+ *) opts=""; titleoptname="-T";;
+ esac
if [ -n "$PRG" ]; then
-# rxvt +sb -sl 500 -n "$title" -title "$title" -e $PRG &
-# exec rxvt +sb -sl 500 -n "$title" -title "$title" -e $PRG
- x-terminal-emulator +sb -sl 500 -n "$title" -title "$title" -e $PRG &
-# x-terminal-emulator $opts -e $PRG &
+# x-terminal-emulator +sb -sl 500 -n "$title" -title "$title" --title "$title" -e $PRG &
+ x-terminal-emulator $opts $titleoptname "$titletext" -e $PRG &
+# exec x-terminal-emulator $opts $titleoptname "$title" -e $PRG &
else
-# rxvt +sb -sl 500 -n "$title" -title "$title" &
-# exec rxvt +sb -sl 500 -n "$title" -title "$title"
- x-terminal-emulator +sb -sl 500 -n "$title" -title "$title" &
-# x-terminal-emulator $opts &
+# exec x-terminal-emulator +sb -sl 500 -n "$title" -title "$title" --title "$title" &
+ x-terminal-emulator $opts $titleoptname "$titletext" &
+# exec x-terminal-emulator $opts $titleoptname "$title" &
fi
}
@@ -61,19 +63,15 @@ while [ $# -gt 0 ]; do
done
set -- $args
-# get hostname unless already given or not there
+# Make sure we have a hostname
if [ -z "$HOST" ]; then
- if [ $# -gt 1 ]; then
+ if [ $# -gt 0 ]; then
HOST=$1
shift
else
HOST="localhost"
fi
fi
-if [ -z "$HOST" ]; then
- usage
- exit 1
-fi
# Split program name from its options
if [ $# -gt 0 ]; then
@@ -97,40 +95,35 @@ if [ "$V" = 1 ]; then
prg_opts="$prg_opts; sleep 4"
fi
-## Don't open 2 shells if no program is run - Disabled for now (something wrong with the test...)
-#if [ -z "$prg_base" -a -z "$prg_opts" -a "$SUU" != 1 ]; then
-# title="$SCRIPT"
-# prg_local=''
-# prg_remote=''
-#else
- if [ -z "$prg_base" ]; then
- title="$SCRIPT"
- prg_base='/bin/bash'
- else
- title="$prg_base"
- prg_opts_local="$prg_opts"
- prg_opts_remote="$prg_opts"
- fi
-
- # Special cases for specific programs
- case $prg_base in
- # Midnight Commander has an option for slow connections
- mc) prg_opts_remote="-s -c $prg_opts_remote";;
- esac
-
- prg_local="$prg_base $prg_opts_local"
- prg_remote="bash --login -i -c \"test -e /etc/debian_version || export TERM=xterm; $prg_base $prg_opts_remote\""
- prg_remote_suu="echo -n 'Changing to root...: '; su $su_opts -c \"cd; $prg_base $prg_opts_remote\""
-#fi
+if [ -z "$prg_base" ]; then
+ title="$SCRIPT"
+ prg_base='/bin/bash'
+else
+ title="$prg_base"
+ prg_opts_local="$prg_opts"
+ prg_opts_remote="$prg_opts"
+fi
+
+# Special cases for specific programs
+case $prg_base in
+ # Force Midnight Commander colors and support slow connections
+ mc) prg_opts_local="-c $prg_opts_local"; prg_opts_remote="-s -c $prg_opts_remote";;
+esac
+
+prg_local="$prg_base $prg_opts_local"
+prg_remote="bash --login -i -c \"test -e /etc/debian_version || export TERM=xterm; $prg_base $prg_opts_remote\""
+prg_remote_suu="echo -n 'Changing to root...: '; su $su_opts -c \"cd; $prg_base $prg_opts_remote\""
if [ "$SU" != 1 ]; then
if [ $HOST = "localhost" ]; then
termwrapper $prg_local
else
+ titleopt="[$HOST]"
termwrapper ssh $ssh_opts $HOST $prg_remote
fi
else
if [ "$SUHACK" = 1 ]; then
+ titleopt="[$HOST]"
# termwrapper ssh $ssh_opts $HOST su $su_opts -c \"$prg_remote\"
termwrapper ssh $ssh_opts $HOST $prg_remote
else