jonty /scr

This shell script is called from my .bashrc for the vi and man commands. If these commands are used from inside GNU screen then they appear as new screens, rather than hogging the shell they were called from. Good for developers.
#! /bin/sh

# ~jonty/bin/scr - Runs a command in a fresh screen
# Jonty 28-Aug-2005

# Get the current directory and the name of command

wd=`pwd`
cmd=$1
shift

## Replace 'man' with 'pinfo' which I prefer
#
#if [[ "$cmd" = "man" ]]
#then
#       cmd=pinfo
#fi

# We can tell if we are running inside screen by looking
# for the STY environment variable.  If it is not set we
# only need to run the command, but if it is set then
# we need to use screen.

if [[ -z "$STY" ]]
then
        $cmd $*
else

        # Screen needs to change directory so that
        # relative file names are resolved correctly.

        screen -X chdir $wd

        # Ask screen to run the command

        screen -X screen -t "$cmd $*" $cmd $*

fi