~kirkland/byobu/trunk

« back to all changes in this revision

Viewing changes to usr/bin/byobu-launcher-install.in

  • Committer: kirkland at ubuntu
  • Date: 2023-11-22 22:45:43 UTC
  • Revision ID: kirkland@ubuntu.com-20231122224543-v5igclwtj4xga8tm
Permanently moved Byobu source code repository to https://github.com/dustinkirkland/byobu

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh -e
2
 
#
3
 
#    byobu-launcher-install
4
 
#    Copyright (C) 2008 Canonical Ltd.
5
 
#
6
 
#    Authors: Nick Barcet <nick.barcet@ubuntu.com>
7
 
#             Dustin Kirkland <kirkland@byobu.org>
8
 
#
9
 
#    This program is free software: you can redistribute it and/or modify
10
 
#    it under the terms of the GNU General Public License as published by
11
 
#    the Free Software Foundation, version 3 of the License.
12
 
#
13
 
#    This program is distributed in the hope that it will be useful,
14
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
#    GNU General Public License for more details.
17
 
#
18
 
#    You should have received a copy of the GNU General Public License
19
 
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 
 
21
 
PKG="byobu"
22
 
[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc"
23
 
[ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="@prefix@" || export BYOBU_PREFIX
24
 
. "${BYOBU_PREFIX}/lib/${PKG}/include/common"
25
 
 
26
 
FLAG="$BYOBU_CONFIG_DIR/no-logout-on-detach"
27
 
 
28
 
LOGOUT_ON_DETACH=1
29
 
for i in $@; do
30
 
        case "$i" in
31
 
                -n|--no-logout)
32
 
                        LOGOUT_ON_DETACH=0
33
 
                ;;
34
 
        esac
35
 
done
36
 
 
37
 
update_flag() {
38
 
        if [ "$LOGOUT_ON_DETACH" = "1" ]; then
39
 
                rm -f "$FLAG"
40
 
        else
41
 
                touch "$FLAG"
42
 
        fi
43
 
}
44
 
 
45
 
install_launcher() {
46
 
        $PKG-launcher-uninstall "$1" || true
47
 
        printf "_byobu_sourced=1 . ${BYOBU_PREFIX}/bin/byobu-launch 2>/dev/null || true\n" >> "$1"
48
 
}
49
 
 
50
 
install_launcher_fish() {
51
 
        $PKG-launcher-uninstall "$1" || true
52
 
        printf "status --is-login; and status --is-interactive; and exec byobu-launcher" >> "$1"
53
 
}
54
 
 
55
 
# Sanitize the environment
56
 
$PKG-launcher-uninstall || true
57
 
 
58
 
# Handle bourne shells, if not set globally in /etc/profile.d
59
 
if [ ! -h "/etc/profile.d/Z97-$PKG.sh" ]; then
60
 
        # Install in $HOME/.profile unconditionally
61
 
        install_launcher "$HOME/.profile"
62
 
        # Now, install in any shell-specific profiles, if they exist
63
 
        # This list may grow to support other shells
64
 
        for i in ".bash_profile" ".bash_login"; do
65
 
                if [ -w "$HOME/$i" ]; then
66
 
                        install_launcher "$HOME/$i"
67
 
                fi
68
 
        done
69
 
fi
70
 
 
71
 
# Install in zprofile if default shell is zsh
72
 
case "$SHELL" in
73
 
        *zsh)
74
 
                install_launcher "$HOME/.zprofile"
75
 
        ;;
76
 
esac
77
 
 
78
 
# Handle fish shell
79
 
if [ -d "$HOME/.config/fish" ]; then
80
 
        install_launcher_fish "$HOME/.config/fish/config.fish"
81
 
fi
82
 
 
83
 
# Hush login, since we will handle motd printing
84
 
touch "$HOME"/.hushlogin
85
 
rm -f "$BYOBU_CONFIG_DIR/disable-autolaunch"
86
 
 
87
 
# Update the logout/nologout flag
88
 
update_flag
89
 
 
90
 
# vi: syntax=sh ts=4 noexpandtab