Skip to content

Instantly share code, notes, and snippets.

@offby1
Created June 19, 2015 17:18
Show Gist options
  • Select an option

  • Save offby1/ae6a2e4a062d6cc185fb to your computer and use it in GitHub Desktop.

Select an option

Save offby1/ae6a2e4a062d6cc185fb to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
#$Id: screen-wrapper.pl 5794 2008-11-30 00:58:30Z erich $
use warnings;
use strict;
use Data::Dumper;
# Save ssh auth stuff somehwere, then start screen.
my $old_umask = umask (077);
my $k = q(SSH_AUTH_SOCK);
my $v = $ENV{$k};
if ($v) {
open (AUTH, ">", "$ENV{HOME}/ssh-auth-stuff") or die;
print AUTH qq(# This file isn't meant to be 'sourced', exactly;\n);
print AUTH qq(# instead it's meant to be read by my emacs function snarf-ssh-auth-stuff\n);
print AUTH qq(# If you _do_ source it, be sure to do 'export $k' afterwards.\n);
print AUTH qq($k=$v\n);
close AUTH or die;
}
umask ($old_umask);
# Make the terminal's title reflect the host name
my $hostname = `hostname`; chomp ($hostname);
print "\033]0;${hostname}\007";
my $l = "$ENV{HOME}/local/bin/screen";
if (-x $l) { exec ($l, @ARGV);}
exec ("screen", @ARGV);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment