mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-21 14:03:18 -07:00
* usr/bin/byobu-enable-prompt, usr/lib/byobu/distro,
usr/lib/byobu/include/shutil, usr/lib/byobu/logo: - use a common get_distro function in a couple of places
This commit is contained in:
parent
a9a74b1c0f
commit
cdb1780181
5 changed files with 55 additions and 62 deletions
3
debian/changelog
vendored
3
debian/changelog
vendored
|
@ -9,6 +9,9 @@ byobu (5.50) unreleased; urgency=low
|
||||||
* usr/bin/byobu-disable-prompt, usr/bin/byobu-enable-prompt:
|
* usr/bin/byobu-disable-prompt, usr/bin/byobu-enable-prompt:
|
||||||
- use ubuntu themed colors for the prompt if running on
|
- use ubuntu themed colors for the prompt if running on
|
||||||
Ubuntu
|
Ubuntu
|
||||||
|
* usr/bin/byobu-enable-prompt, usr/lib/byobu/distro,
|
||||||
|
usr/lib/byobu/include/shutil, usr/lib/byobu/logo:
|
||||||
|
- use a common get_distro function in a couple of places
|
||||||
|
|
||||||
-- Dustin Kirkland <kirkland@ubuntu.com> Sun, 28 Jul 2013 19:51:39 -0500
|
-- Dustin Kirkland <kirkland@ubuntu.com> Sun, 28 Jul 2013 19:51:39 -0500
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,9 @@ PKG="byobu"
|
||||||
[ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX
|
[ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX
|
||||||
. "${BYOBU_PREFIX}/lib/${PKG}/include/common"
|
. "${BYOBU_PREFIX}/lib/${PKG}/include/common"
|
||||||
|
|
||||||
|
get_distro
|
||||||
|
DISTRO="$_RET"
|
||||||
byobu-disable-prompt || true
|
byobu-disable-prompt || true
|
||||||
DISTRO=$(lsb_release -s -d)
|
|
||||||
case $DISTRO in
|
case $DISTRO in
|
||||||
Ubuntu*)
|
Ubuntu*)
|
||||||
cat >>"$HOME/.bashrc" <<EOF
|
cat >>"$HOME/.bashrc" <<EOF
|
||||||
|
|
|
@ -28,47 +28,10 @@ __distro() {
|
||||||
if [ -n "$DISTRO" ]; then
|
if [ -n "$DISTRO" ]; then
|
||||||
# user defined
|
# user defined
|
||||||
true
|
true
|
||||||
elif [ -r "/etc/issue" ]; then
|
|
||||||
# lsb_release is *really* slow; try to use /etc/issue first
|
|
||||||
local issue
|
|
||||||
IFS="" read issue < /etc/issue
|
|
||||||
case "$issue" in
|
|
||||||
Ubuntu*)
|
|
||||||
DISTRO="Ubuntu";
|
|
||||||
;;
|
|
||||||
Debian*)
|
|
||||||
DISTRO="Debian"
|
|
||||||
;;
|
|
||||||
Red\ Hat\ Enterprise*)
|
|
||||||
DISTRO="RHEL"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# assume first field is what we want
|
|
||||||
DISTRO="${issue%% *}";
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
elif $BYOBU_TEST lsb_release >/dev/null 2>&1; then
|
|
||||||
# If lsb_release is available, use it
|
|
||||||
local r=$(lsb_release -s -d)
|
|
||||||
case "$r" in
|
|
||||||
Ubuntu*)
|
|
||||||
# Use the -d if an Ubuntu LTS
|
|
||||||
DISTRO="Ubuntu"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# But for other distros the description
|
|
||||||
# is too long, so build from -i and -r
|
|
||||||
DISTRO=$(lsb_release -s -i)
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
elif $BYOBU_TEST sw_vers >/dev/null 2>&1; then
|
|
||||||
DISTRO="$(sw_vers -productName)"
|
|
||||||
elif $BYOBU_TEST uname >/dev/null 2>&1; then
|
|
||||||
DISTRO="$(uname -s)"
|
|
||||||
else
|
else
|
||||||
DISTRO="Byobu"
|
get_distro
|
||||||
|
DISTRO="$_RET"
|
||||||
fi
|
fi
|
||||||
[ -n "$DISTRO" ] || return
|
|
||||||
color bold2; printf "%s" "$DISTRO"; color --
|
color bold2; printf "%s" "$DISTRO"; color --
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -310,4 +310,52 @@ get_network_interface() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_distro() {
|
||||||
|
local distro="${DISTRO}"
|
||||||
|
if [ -n "$DISTRO" ]; then
|
||||||
|
# user defined
|
||||||
|
true
|
||||||
|
elif [ -r "/etc/issue" ]; then
|
||||||
|
# lsb_release is *really* slow; try to use /etc/issue first
|
||||||
|
local issue
|
||||||
|
IFS="" read issue < /etc/issue
|
||||||
|
case "$issue" in
|
||||||
|
Ubuntu*)
|
||||||
|
distro="Ubuntu";
|
||||||
|
;;
|
||||||
|
Debian*)
|
||||||
|
distro="Debian"
|
||||||
|
;;
|
||||||
|
Red\ Hat\ Enterprise*)
|
||||||
|
distro="RHEL"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# assume first field is what we want
|
||||||
|
distro="${issue%% *}";
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
elif $BYOBU_TEST lsb_release >/dev/null 2>&1; then
|
||||||
|
# If lsb_release is available, use it
|
||||||
|
local r=$(lsb_release -s -d)
|
||||||
|
case "$r" in
|
||||||
|
Ubuntu*)
|
||||||
|
# Use the -d if an Ubuntu LTS
|
||||||
|
distro="Ubuntu"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# But for other distros the description
|
||||||
|
# is too long, so build from -i and -r
|
||||||
|
distro=$(lsb_release -s -i)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
elif $BYOBU_TEST sw_vers >/dev/null 2>&1; then
|
||||||
|
distro="$(sw_vers -productName)"
|
||||||
|
elif $BYOBU_TEST uname >/dev/null 2>&1; then
|
||||||
|
distro="$(uname -s)"
|
||||||
|
else
|
||||||
|
distro="Byobu"
|
||||||
|
fi
|
||||||
|
_RET="$distro"
|
||||||
|
}
|
||||||
|
|
||||||
# vi: syntax=sh ts=4 noexpandtab
|
# vi: syntax=sh ts=4 noexpandtab
|
||||||
|
|
|
@ -19,28 +19,6 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
get_distro() {
|
|
||||||
_RET=
|
|
||||||
if [ -n "$DISTRO" ]; then
|
|
||||||
# Allow manual override of distro in $BYOBU_CONFIG_DIR/status
|
|
||||||
_RET="$DISTRO"
|
|
||||||
elif [ -r "/etc/issue" ]; then
|
|
||||||
# Otherwise, check /etc/issue
|
|
||||||
_RET=`grep -m1 "^[A-Za-z]" /etc/issue`
|
|
||||||
elif $BYOBU_TEST lsb_release >/dev/null 2>&1; then
|
|
||||||
# This can be a very expensive operation, do it only
|
|
||||||
# if all other methods fail
|
|
||||||
_RET=`lsb_release -s -a 2>/dev/null`
|
|
||||||
elif $BYOBU_TEST sw_vers >/dev/null 2>&1; then
|
|
||||||
_RET=`sw_vers 2>/dev/null`
|
|
||||||
elif $BYOBU_TEST uname >/dev/null 2>&1; then
|
|
||||||
_RET=`uname -s`
|
|
||||||
else
|
|
||||||
# No idea!
|
|
||||||
_RET="[B]"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
__logo_detail() {
|
__logo_detail() {
|
||||||
MARKUP="false"
|
MARKUP="false"
|
||||||
__logo
|
__logo
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue