* usr/lib/byobu/battery, usr/lib/byobu/color, usr/lib/byobu/date,

usr/lib/byobu/.shutil, usr/lib/byobu/time,
  usr/share/byobu/profiles/Makefile.am, usr/share/byobu/profiles/tmux:
  - create tmux color mappings and functions
  - get date/time working in tmux (need to figure out how to get
    tmux to interpret the time format sequence)
  - install the tmux profile
  - get the tmux profile using the new status print methodology
This commit is contained in:
Dustin Kirkland 2011-07-10 19:15:43 +01:00
commit e978fb30b6
8 changed files with 111 additions and 21 deletions

8
debian/changelog vendored
View file

@ -61,6 +61,14 @@ byobu (4.18) unreleased; urgency=low
- significantly reduce the number of mkdir -p commands - significantly reduce the number of mkdir -p commands
* usr/bin/byobu-status-print: * usr/bin/byobu-status-print:
- save a few forks - save a few forks
* usr/lib/byobu/battery, usr/lib/byobu/color, usr/lib/byobu/date,
usr/lib/byobu/.shutil, usr/lib/byobu/time,
usr/share/byobu/profiles/Makefile.am, usr/share/byobu/profiles/tmux:
- create tmux color mappings and functions
- get date/time working in tmux (need to figure out how to get
tmux to interpret the time format sequence)
- install the tmux profile
- get the tmux profile using the new status print methodology
[ James Spencer ] [ James Spencer ]
* usr/lib/byobu/.constants: * usr/lib/byobu/.constants:

View file

@ -41,8 +41,63 @@ color_screen() {
esac esac
} }
color_map() {
case "$1" in
k) _RET=black ;;
r) _RET=red ;;
g) _RET=green ;;
y) _RET=yellow ;;
b) _RET=blue ;;
m) _RET=magenta ;;
c) _RET=cyan ;;
w) _RET=white ;;
d) _RET=color0 ;;
K) _RET=black,bold ;;
R) _RET=red,bold ;;
G) _RET=green,bold ;;
Y) _RET=yellow,bold ;;
B) _RET=blue,bold ;;
M) _RET=magenta,bold ;;
C) _RET=cyan,bold ;;
W) _RET=white,bold ;;
*) _RET= ;;
esac
}
attr_map() {
case "$1" in
d) _RET=,dim ;;
u) _RET=,underline ;;
b) _RET=,bold ;;
r) _RET=,reverse ;;
s) _RET=,standout ;;
B) _RET=,blinking ;;
*) _RET= ;;
esac
}
color_tmux() { color_tmux() {
true ESC="\005"
case "$1" in
"") return 0 ;;
-) printf "#[default]" ;;
--) printf "#[default] " ;;
esc) printf "" ;;
bold*) printf "#[fg=bold]" ;;
none) printf "#[default]" ;;
invert) printf "#[reverse]" ;;
*)
if [ "$#" = "2" ]; then
color_map "$1"; back="$_RET"
color_map "$2"; fore="$_RET"
else
attr_map "$1"; attr="$_RET"
color_map "$2"; back="$_RET"
color_map "$3"; fore="$_RET"
fi
[ "$MONOCHROME" = "1" ] && printf "#[default]" || printf "#[fg=$fore$attr,bg=$back]"
;;
esac
} }
color() { color() {
@ -167,7 +222,7 @@ status_freq() {
cpu_freq) _RET=2 ;; cpu_freq) _RET=2 ;;
cpu_temp) _RET=19 ;; cpu_temp) _RET=19 ;;
custom) _RET=5 ;; custom) _RET=5 ;;
date) _RET=28793 ;; date) [ "$BYOBU_BACKEND" = "tmux" ] && _RET=1 || _RET=28793 ;;
disk) _RET=13 ;; disk) _RET=13 ;;
disk_io) _RET=3 ;; disk_io) _RET=3 ;;
ec2_cost) _RET=601 ;; ec2_cost) _RET=601 ;;
@ -189,7 +244,7 @@ status_freq() {
release) _RET=599 ;; release) _RET=599 ;;
services) _RET=53 ;; services) _RET=53 ;;
swap) _RET=19 ;; swap) _RET=19 ;;
time) _RET=9999999 ;; time) [ "$BYOBU_BACKEND" = "tmux" ] && _RET=1 || _RET=9999999 ;;
time_binary) _RET=23 ;; time_binary) _RET=23 ;;
time_utc) _RET=11 ;; time_utc) _RET=11 ;;
trash) _RET=9999999 ;; trash) _RET=9999999 ;;

View file

@ -54,14 +54,14 @@ __battery() {
done < "$bat/state" done < "$bat/state"
percent=$(((100*$rem)/$full)) percent=$(((100*$rem)/$full))
if [ "$percent" -lt 33 ]; then if [ "$percent" -lt 33 ]; then
color="R k" color="R w"
bcolor="b R k" bcolor="b R w"
elif [ "$percent" -lt 67 ]; then elif [ "$percent" -lt 67 ]; then
color="Y k" color="Y w"
bcolor="b Y k" bcolor="b Y w"
else else
color="G k" color="G w"
bcolor="b G k" bcolor="b G w"
fi fi
percent="$percent%" percent="$percent%"
case $state in case $state in

View file

@ -23,9 +23,16 @@ __color_detail() {
} }
__color() { __color() {
[ -z "$FOREGROUND" ] && FOREGROUND="w" case "$BYOBU_BACKEND" in
[ -z "$BACKGROUND" ] && BACKGROUND="k" tmux)
printf "\005{= $BACKGROUND$FOREGROUND}" true
;;
*)
[ -z "$FOREGROUND" ] && FOREGROUND="w"
[ -z "$BACKGROUND" ] && BACKGROUND="k"
printf "\005{= $BACKGROUND$FOREGROUND}"
;;
esac
} }
# vi: syntax=sh ts=4 noexpandtab # vi: syntax=sh ts=4 noexpandtab

View file

@ -24,9 +24,16 @@ __date_detail() {
} }
__date() { __date() {
bd=$(date "+%m%d") case "$BYOBU_BACKEND" in
[ "$bd" = "0320" ] && msg="$(echo SGFwcHkgQmlydGhkYXkgU2NyZWVuIC0tIGh0dHA6Ly9iaXQubHkvc2NyZWVuLWJkYXkK | base64 -di)" && $BYOBU_BACKEND -X -S "byobu" at "*" echo "[$msg]" tmux)
color none; printf "\005Y-\005m-\005d"; color -- date +"%Y-%m-%d"
;;
*)
bd=$(date "+%m%d")
[ "$bd" = "0320" ] && msg="$(echo SGFwcHkgQmlydGhkYXkgU2NyZWVuIC0tIGh0dHA6Ly9iaXQubHkvc2NyZWVuLWJkYXkK | base64 -di)" && $BYOBU_BACKEND -X -S "byobu" at "*" echo "[$msg]"
color none; printf "\005Y-\005m-\005d"; color --
;;
esac
} }
# vi: syntax=sh ts=4 noexpandtab # vi: syntax=sh ts=4 noexpandtab

View file

@ -24,7 +24,14 @@ __time_detail() {
} }
__time() { __time() {
printf "\0050c:\005s" case "$BYOBU_BACKEND" in
tmux)
date +"%H:%M:%S"
;;
*)
printf "\0050c:\005s"
;;
esac
} }
# vi: syntax=sh ts=4 noexpandtab # vi: syntax=sh ts=4 noexpandtab

View file

@ -1,2 +1,2 @@
profilesdir = $(datadir)/@PACKAGE@/profiles profilesdir = $(datadir)/@PACKAGE@/profiles
profiles_DATA = byoburc screenrc common NONE profiles_DATA = byoburc screenrc common tmux NONE

View file

@ -47,9 +47,11 @@ bind-key -n S-F4 select-pane -R
bind-key -n C-F6 kill-pane bind-key -n C-F6 kill-pane
set-option -g set-titles on set-option -g set-titles on
set-option -g set-titles-string '#(whoami)@#H - #S' set-option -g set-titles-string '#(whoami)@#H - byobu (#S)'
set-window-option -g window-status-current-bg red set-window-option -g window-status-attr bold
set-window-option -g window-status-current-bg white
set-window-option -g window-status-current-fg black
set-window-option -g automatic-rename on set-window-option -g automatic-rename on
set-window-option -g aggressive-resize on set-window-option -g aggressive-resize on
#set-window-option -g xterm-keys on #set-window-option -g xterm-keys on
@ -61,5 +63,9 @@ set -g default-command /bin/bash
set -g status-bg black set -g status-bg black
set -g status-fg white set -g status-fg white
set -g status-interval 1 set -g status-interval 1
set -g status-left '#[fg=white,bold,bg=magenta] U ' set -g status-left-length 256
set -g status-right '%Y-%m-%d %H:%M:%S' set -g status-right-length 256
set -g status-left '#(byobu-status-print 3)['
set -g status-right ']#(byobu-status-print 4)'
set -g message-bg magenta
set -g message-fg white