8 screenreattach - Reattach to GNU/screen and import environment variables
17 .
/usr
/lib
/tool
/bash-utils
21 declare -a screen_names
28 local anything
=`find "$dir" -mindepth 1 -maxdepth 1 -print 1 -quit`
48 if [ ".${1:0:1}" != .
- ]
57 if [ -z "$screen_name" ]
59 screendir
=${SCREENDIR:-/var/run/screen/S-$USER}
60 if [ ! -d "$screendir" ] || is_dir_empty
"$screendir"
62 screendir
=/tmp
/uscreens
/S-
$USER
65 screen_names
=(`find "$screendir" -mindepth 1 -maxdepth 1 ! -name '.*' -printf "%f\n" 2>/dev/null`)
67 if [ ${#screen_names[@]} = 1 ]
70 screen_name
=${screen_names[0]}
71 elif [ ${#screen_names[@]} -gt 1 ]
73 new_screen_str
=$
'\t'"New Screen"
74 while [ -z "$screen_name" ]
78 select screen_desc
in `screen -ls | sed -e '$d' | sed -n -e '/^\S/ w/dev/stderr' -e '/^\s/ p'` "$new_screen_str"
80 if [ "$screen_desc" = "$new_screen_str" ]
85 screen_name
=$tty.
${COLUMNS:-$(tput cols)}x
${LINES:-$(tput lines)}
87 elif [ -n "$screen_desc" ]
90 screen_name
=`sed -e 's/\s*\(\S\+\).*/\1/' <<<"$screen_desc"`
96 argv
+=("$screen_name")
104 if [ $new_screen != 1 -a -n "$screen_name" ]
107 for env
in DISPLAY SSH_AUTH_SOCK DBUS_SESSION_BUS_ADDRESS XDG_SESSION_COOKIE WINDOWID
109 if bash_defined
"$env"
111 echo "setting $env in $screen_name screen" >&2
112 screen
${screen_name:+-S "$screen_name"} -X setenv
"$env" "${!env}"
122 exec screen
"${argv[@]}"