#!/bin/bash # A problem I've been trying to solve for a long time. To start a # remote emacs client in the background, the ssh session needs to stay # alive to forward the connection and emacsclient on the remote host # needs stdin to be a terminal. I've only ever found two ways to work # around this: use dtach or screen, or do the login manually and wait # until the X window is open. It seems that then there is no longer # any attempt to access the controlling tty. # I'm using dtach instead of screen as it's uses a single socket per # terminal and doesn't require config files. [ -z "$2" ] && echo "usage: $0 [ ...]" && exit 1 HOST=$1 shift SOCKET=$(mktemp "/tmp/$HOST.$(basename $1).XXXX") # race possible but higly unlikely rm $SOCKET # echo "SOCKET=$SOCKET" # Can't share a non-X master session, so be own master. # set -x dtach -c $SOCKET ssh -XM $HOST -t "$@" # dtach -n $SOCKET ssh -XM $HOST -t "$@" # I don't understand this shit...