#!/bin/bash # *** PRELIMINARY NOTE *** # Due to a bug in dash[*], and as dash can be the /bin/sh implementation, # /bin/bash is used here everywhere /bin/sh should have been used. If you # do not have /bin/bash installed, you can replace these occurrences by # another working shell (zsh is OK). # # [*] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=683671 # i.e. a Ctrl-G in Emacs 24 would make the command fail # (killed by SIGINT). # This script should be used as a replacement for /bin/sh by text programs # that can run X applications. Its goal is to update the environment when # such programs run in a screen session that survives across X sessions. # # The "escreen" wrapper needs to be run instead of "screen" when resuming # a screen session. This wrapper will create a .screenenv/$STY file with # the correct values of the environment variables DISPLAY, XAUTHORITY and # DBUS_SESSION_BUS_ADDRESS. # # A bit more may be needed to make this work with various software. # For instance: # # * Mutt: you should recompile Mutt with the following configure option: # # --with-exec-shell=/path/to/sh.screen # # Then you will be able to run Mutt from screen and run X applications # (e.g., compose editor, shell commands, mailcap applications) from it # across X sessions. # # * Zsh: add the following two lines to the preexec function: # # local envfile=$HOME/.screenenv/$STY # [[ -f $envfile ]] && source $envfile # Source the file correcting the environment. if [ -n "$STY" ]; then envfile=$HOME/.screenenv/$STY [ -f "$envfile" ] && . "$envfile" fi # Try to guess what the real shell should be. if [ -n "$SHSCREEN_SHELL" ]; then shell=$SHSCREEN_SHELL else case $0 in *sh.screen) shell=/bin/bash ;; sh) shell=/bin/bash ;; *) shell=$0 ;; esac fi # Execute the real shell with the unmodified arguments. exec "$shell" ${@+"$@"} # $Id: sh.screen 70575 2014-06-22 19:25:20Z vinc17/xvii $