Skip to content

Instantly share code, notes, and snippets.

@audiodude
Created March 1, 2011 21:21
Show Gist options
  • Save audiodude/849925 to your computer and use it in GitHub Desktop.
Save audiodude/849925 to your computer and use it in GitHub Desktop.
Export your SSH variables for use with GNU screen
  1. Put scratch in ~/bin/
  2. Put itch in your .bashrc
  3. Start screen with ‘scratch’ instead of screen (SCReen ATtaCH)
  4. As soon as you’re in your screen, if it’s not a new screen, `itch` that scratch!

Thanks to Samat Jane

# Put this in your .bashrc
alias itch='source "$HOME/.screen/session-variables"'
#!/bin/bash
# Wrapper script for screen
if [ -n "$SSH_CLIENT" ]; then
mkdir -p "$HOME/.screen"
# Variables to save
SSHVARS="SSH_CLIENT SSH_TTY SSH_AUTH_SOCK SSH_CONNECTION DISPLAY"
for x in ${SSHVARS} ; do
(eval echo $x=\$$x) | sed 's/=/="/
s/$/"/
s/^/export /'
done 1> "$HOME/.screen/session-variables"
fi
exec screen -d -R -A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment