3
# byobu-launcher - conditionally launch byobu
4
# Copyright (C) 2010 Canonical Ltd.
6
# Authors: Dustin Kirkland <kirkland@canonical.com>
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, version 3 of the License.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
if [ ! -r "$HOME/.byobu/disable-autolaunch" ]; then
21
if printf "$TERM" | grep -qs "screen"; then
23
printf "$(gettext 'Do you want to launch byobu in a nested session?') [y/N]: "
25
if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
26
# Prevent nasty launch recursion, if ssh'ing to localhost
27
if [ -n "$SSH_CONNECTION" ]; then
28
# This is an SSH session
29
from=$(echo "$SSH_CONNECTION" | awk '{print $1}')
30
to=$(echo "$SSH_CONNECTION" | awk '{print $3}')
31
if [ "$from" = "$to" ]; then
32
# We have ssh'd from this machine, to this machine
33
if screen -ls | grep -qs '(Attached)$'; then
34
# And there is already an attached screen session
35
# Exit to prevent recursion
38
exec /usr/bin/byobu "$@"
41
exec /usr/bin/byobu "$@"
44
exec /usr/bin/byobu "$@"
50
exec /usr/bin/byobu "$@"