From 692a34bdf0717bde5f8f0d65abe63509634efbfe Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Sun, 8 Jan 2012 18:26:52 -0600 Subject: [PATCH] * usr/lib/byobu/include/layout => usr/bin/byobu-layout, usr/share/byobu/keybindings/f-keys.tmux, usr/share/man/man1/byobu- layout.1: - move the layout library utility to a generally usable byobu-layout in the system path - add specific named layout support to both save and restore operations - add a manpage --- debian/changelog | 7 +++ .../byobu/include/layout => bin/byobu-layout} | 60 ++++++++++--------- usr/share/byobu/keybindings/f-keys.tmux | 4 +- usr/share/man/man1/byobu-layout.1 | 25 ++++++++ 4 files changed, 67 insertions(+), 29 deletions(-) rename usr/{lib/byobu/include/layout => bin/byobu-layout} (77%) create mode 100644 usr/share/man/man1/byobu-layout.1 diff --git a/debian/changelog b/debian/changelog index 176758af..e32d8574 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,13 @@ byobu (5.2) unreleased; urgency=low - save some space in the tarball * usr/lib/byobu/logo: - add a linux mint logo + * usr/lib/byobu/include/layout => usr/bin/byobu-layout, + usr/share/byobu/keybindings/f-keys.tmux, usr/share/man/man1/byobu- + layout.1: + - move the layout library utility to a generally usable byobu-layout + in the system path + - add specific named layout support to both save and restore operations + - add a manpage -- Dustin Kirkland Thu, 29 Dec 2011 12:28:51 -0600 diff --git a/usr/lib/byobu/include/layout b/usr/bin/byobu-layout similarity index 77% rename from usr/lib/byobu/include/layout rename to usr/bin/byobu-layout index 7760f3f3..0cb3fcb0 100755 --- a/usr/lib/byobu/include/layout +++ b/usr/bin/byobu-layout @@ -69,37 +69,43 @@ case "$1" in printf "$panes\n$layout\n" > "$BYOBU_CONFIG_DIR/layouts/$name" ;; "restore") - # List the saved layouts, prompt the user to select one - list_layouts - count="$_RET" - while true; do - echo -n "Select a layout to restore [1-$count]: " - selected=$(head -n1) - if [ -n "$selected" ] && [ $selected -le $count ] && [ $selected -ge 1 ]; then - break - fi - done + if [ -n "$2" ]; then + # Layout selected on the command line + name="$2" + else + # List the saved layouts, prompt the user to select one + list_layouts + count="$_RET" + while true; do + echo -n "Select a layout to restore [1-$count]: " + selected=$(head -n1) + if [ -n "$selected" ] && [ $selected -le $count ] && [ $selected -ge 1 ]; then + break + fi + done + count=0 + for i in $PRESETS "$DIR"/*; do + count=$(expr $count + 1) + if [ $count -eq $selected ]; then + name=$(basename "$i") + break + fi + done + fi # Get the details of the selected layout - count=0 panes= layout= - for i in $PRESETS "$DIR"/*; do - count=$(expr $count + 1) - if [ $count -eq $selected ]; then - if [ -f "$i" ]; then - panes=$(head -n1 "$i") - layout=$(tail -n1 "$i") - else - if [ $current_panes -eq 1 ]; then - panes=4 - else - panes=0 - fi - layout="$i" - fi - break + if [ -f "$DIR/$name" ]; then + panes=$(head -n1 "$DIR/$name") + layout=$(tail -n1 "$DIR/$name") + else + if [ $current_panes -eq 1 ]; then + panes=4 + else + panes=0 fi - done + layout="$name" + fi # Create panes if nececessary to restore the layout while [ $(tmux list-panes | wc -l) -lt $panes ]; do tmux split-window diff --git a/usr/share/byobu/keybindings/f-keys.tmux b/usr/share/byobu/keybindings/f-keys.tmux index 65f605fd..13abe6f3 100644 --- a/usr/share/byobu/keybindings/f-keys.tmux +++ b/usr/share/byobu/keybindings/f-keys.tmux @@ -61,8 +61,8 @@ bind-key -n M-NPage copy-mode \; send-keys NPage bind-key -n M-PPage copy-mode \; send-keys PPage bind-key -n F8 command-prompt -p "(rename-window)" "rename-window %%" bind-key -n S-F8 next-layout -bind-key -n C-F8 new-window -k "$BYOBU_PREFIX/lib/byobu/include/layout restore; clear; $SHELL" -bind-key -n C-S-F8 command-prompt -p "Save byobu layout as:" "run-shell '$BYOBU_PREFIX/lib/byobu/include/layout save %%'" +bind-key -n C-F8 new-window -k "byobu-layout restore; clear; $SHELL" +bind-key -n C-S-F8 command-prompt -p "Save byobu layout as:" "run-shell 'byobu-layout save %%'" bind-key -n F9 new-window -k -n config byobu-config bind-key -n M-F11 break-pane bind-key -n C-F11 join-pane -h -s :. -t :-1 diff --git a/usr/share/man/man1/byobu-layout.1 b/usr/share/man/man1/byobu-layout.1 new file mode 100644 index 00000000..1d470bc5 --- /dev/null +++ b/usr/share/man/man1/byobu-layout.1 @@ -0,0 +1,25 @@ +.TH byobu-layout 1 "8 Jan 2012" byobu "byobu" +.SH NAME +byobu\-layout \- Save and restore byobu-tmux laouts + +.SH USAGE +byobu\-layout [save|restore] [name] + +.SH DESCRIPTION +\fBbyobu\-layout\fP will save and restore \fBbyobu-tmux\fP(1) split window layouts. + +If 'name' is blank, it operates interactively. + +Note that this only works with Byobu when backed by \fBtmux\fP(1), and not \fBscreen\fP(1). + +.SH SEE ALSO +\fBbyobu\fP(1), \fBtmux\fP(1) + +.TP +\fIhttp://launchpad.net/byobu\fP +.PD + +.SH AUTHOR +This manpage and the utility were written by Dustin Kirkland for Ubuntu systems (but may be used by others). Permission is granted to copy, distribute and/or modify this document and the utility under the terms of the GNU General Public License, Version 3 published by the Free Software Foundation. + +The complete text of the GNU General Public License can be found in \fI/usr/share/common-licenses/GPL\fP on Debian/Ubuntu systems, or in \fI/usr/share/doc/fedora-release-*/GPL\fP on Fedora systems, or on the web at \fIhttp://www.gnu.org/licenses/gpl.txt\fP.