* usr/bin/byobu, usr/lib/byobu/ip_address, usr/share/man/man1/byobu.1:

- support IP_EXTERNAL fetching, LP: #873736
  - put ip address in the terminal title bar, since we ran out of room
    for it in tmux
This commit is contained in:
Dustin Kirkland 2011-10-22 00:38:04 -05:00
commit 3dd87d8db3
4 changed files with 25 additions and 10 deletions

5
debian/changelog vendored
View file

@ -1,6 +1,9 @@
byobu (4.43) unreleased; urgency=low
* UNRELEASED
* usr/bin/byobu, usr/lib/byobu/ip_address, usr/share/man/man1/byobu.1:
- support IP_EXTERNAL fetching, LP: #873736
- put ip address in the terminal title bar, since we ran out of room
for it in tmux
-- Dustin Kirkland <kirkland@ubuntu.com> Fri, 21 Oct 2011 13:43:57 -0500

View file

@ -63,7 +63,9 @@ fi
byobu-janitor --force
# Set the window title
[ -n "$BYOBU_NO_TITLE" ] || printf "\033]0;${USER}@${HOSTNAME:-$(hostname)} - ${PKG}\007"
[ -r "$BYOBU_CONFIG_DIR/statusrc" ] && . "$BYOBU_CONFIG_DIR/statusrc"
. $BYOBU_PREFIX/lib/$PKG/ip_address
[ -n "$BYOBU_NO_TITLE" ] || printf "\033]0;${USER}@${HOSTNAME:-$(hostname)} ($(__ip_address t)) - ${PKG}\007"
# Drop a symlink to the ssh socket in $HOME, since we can ensure that exists
if [ -S "$SSH_AUTH_SOCK" ] && [ ! -h "$SSH_AUTH_SOCK" ]; then

View file

@ -38,14 +38,20 @@ __ip_address() {
fi
case "$IPV6" in
1|true|yes)
ipaddr=$(LC_ALL=C /sbin/ip -6 addr list dev "$interface" scope global)
# Print 'None' if we have no global address
[ -z "$ipaddr" ] && ipaddr="None"
ipaddr=${ipaddr#* inet6 }
ipaddr=${ipaddr%%/*}
if [ "$IP_EXTERNAL" = "1" ]; then
ipaddr=$(wget -O- -q http://v6.ipv6-test.com/api/myip.php)
else
ipaddr=$(LC_ALL=C /sbin/ip -6 addr list dev "$interface" scope global)
# Print 'None' if we have no global address
[ -z "$ipaddr" ] && ipaddr="None"
ipaddr=${ipaddr#* inet6 }
ipaddr=${ipaddr%%/*}
fi
;;
*)
if metadata_available; then
if [ "$IP_EXTERNAL" = "1" ]; then
ipaddr=$(wget -O- -q http://v4.ipv6-test.com/api/myip.php)
elif metadata_available; then
# We're in EC2, so get our public IP address
ipaddr=$(wget -q -O- http://169.254.169.254/latest/meta-data/public-ipv4)
else
@ -56,7 +62,11 @@ __ip_address() {
;;
esac
if [ -n "$ipaddr" ]; then
color bold2; printf "%s" "$ipaddr"; color --
if [ "$1" = "t" ]; then
printf "%s" "$ipaddr"
else
color bold2; printf "%s" "$ipaddr"; color --
fi
fi
}

View file

@ -51,7 +51,7 @@ Note that BYOBU_CONFIG_DIR=\fI$XDG_CONFIG_HOME/byobu\fP if defined, and \fI$HOME
\fBhostname\fP \- the hostname of the system; displayed in the upper bar on the far right in bold black text on a grey background; there is a leading '@' symbol if the username status is also enabled
\fBip_address\fP \- the IPv4 address of the system in dotted decimal form; displayed in the upper bar on the far right in bold black text on a grey background; you can override and display your IPv6 address by setting 'IPV6=1' in \fI$BYOBU_CONFIG_DIR/statusrc\fP
\fBip_address\fP \- the IPv4 address of the system in dotted decimal form; displayed in the upper bar on the far right in bold black text on a grey background; you can override and display your IPv6 address by setting 'IPV6=1', and you can show your external ip address by setting 'IP_EXTERNAL=1' in \fI$BYOBU_CONFIG_DIR/statusrc\fP
\fBload_average\fP \- the system load average over the last 1 minute; displayed in the lower bar toward the right in black text on a yellow background