~ubuntu-branches/debian/wheezy/byobu/wheezy

« back to all changes in this revision

Viewing changes to usr/bin/byobu-launcher

  • Committer: Bazaar Package Importer
  • Author(s): Philipp Kern
  • Date: 2010-06-28 18:04:16 UTC
  • mfrom: (0.5.1 upstream) (0.3.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100628180416-3xgfpga8cvp872ye
Upload to Debian unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh -e
 
2
#
 
3
#    byobu-launcher - conditionally launch byobu
 
4
#    Copyright (C) 2010 Canonical Ltd.
 
5
#
 
6
#    Authors: Dustin Kirkland <kirkland@canonical.com>
 
7
#
 
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.
 
11
#
 
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.
 
16
#
 
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/>.
 
19
 
 
20
if [ ! -r "$HOME/.byobu/disable-autolaunch" ]; then
 
21
        if printf "$TERM" | grep -qs "screen"; then
 
22
                # Handle nesting
 
23
                printf "$(gettext 'Do you want to launch byobu in a nested session?') [y/N]: "
 
24
                answer=$(head -n1)
 
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
 
36
                                                false
 
37
                                        else
 
38
                                                exec /usr/bin/byobu "$@"
 
39
                                        fi
 
40
                                else
 
41
                                        exec /usr/bin/byobu "$@"
 
42
                                fi
 
43
                        else
 
44
                                exec /usr/bin/byobu "$@"
 
45
                        fi
 
46
                else
 
47
                        false
 
48
                fi
 
49
        else
 
50
                exec /usr/bin/byobu "$@"
 
51
        fi
 
52
fi
 
53
false