#!/usr/bin/env zsh # rlogin to host and set the DISPLAY # written by Vincent Lefevre # Usage: dlogin [-] [opts] host # TERM is rewritten $TERM^$DISPLAY (a / as a separator instead of ^ would # be simpler, but the /* part is stripped by rlogin, so this doesn't work). # The .zshenv on host should contain: # if [[ $TERM == *^* ]] then # export DISPLAY=${TERM#*\^} # export TERM=${TERM%\^*} # fi # The .cshrc on host should contain: # if ($?TERM) then # if ("$TERM" =~ *^*) then # setenv DISPLAY $TERM:s#^#/#:t # setenv TERM $TERM:s#^#/#:h # endif # endif emulate -LR zsh local xauth display exec if [[ $1 == - ]] then shift xauth=1 fi if [[ $# -eq 0 ]] then echo "usage: dlogin [-] [opts] host" return 1 fi if [[ -n "$DISPLAY" ]] then display=${DISPLAY/#:/${HOST}:} if [[ -n "$xauth" ]] then echo "xauth..." xauth extract - $display | rsh $*[-1] xauth merge - fi fi # exec rlogin if dlogin was started in a subshell [[ -o interactive ]] || exec=exec eval $exec env TERM="$TERM${display:+^$display}" rlogin "$@" # $Id: dlogin 29255 2009-05-13 12:17:47Z vinc17/vin $