mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-21 22:13:19 -07:00
* usr/lib/byobu/include/layout, usr/lib/byobu/include/Makefile.am,
usr/share/byobu/keybindings/f-keys.tmux, usr/share/byobu/keybindings/f-keys.tmux.disable, usr/share/doc/byobu/help.tmux.txt: LP: #902416 - new feature to save layouts using ctrl-shift-F8, and restore layouts using shift-F8
This commit is contained in:
parent
c67b0772d0
commit
b1bf57b3da
6 changed files with 132 additions and 6 deletions
7
debian/changelog
vendored
7
debian/changelog
vendored
|
@ -1,6 +1,11 @@
|
||||||
byobu (4.54) unreleased; urgency=low
|
byobu (4.54) unreleased; urgency=low
|
||||||
|
|
||||||
* UNRELEASED
|
* usr/lib/byobu/include/layout, usr/lib/byobu/include/Makefile.am,
|
||||||
|
usr/share/byobu/keybindings/f-keys.tmux,
|
||||||
|
usr/share/byobu/keybindings/f-keys.tmux.disable,
|
||||||
|
usr/share/doc/byobu/help.tmux.txt: LP: #902416
|
||||||
|
- new feature to save layouts using ctrl-shift-F8, and restore layouts
|
||||||
|
using shift-F8
|
||||||
|
|
||||||
-- Dustin Kirkland <kirkland@ubuntu.com> Thu, 08 Dec 2011 12:15:18 -0600
|
-- Dustin Kirkland <kirkland@ubuntu.com> Thu, 08 Dec 2011 12:15:18 -0600
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
inclibdirdir = $(prefix)/lib/@PACKAGE@/include
|
inclibdirdir = $(prefix)/lib/@PACKAGE@/include
|
||||||
inclibdir_SCRIPTS = common constants dirs mondrian notify_osd shutil
|
inclibdir_SCRIPTS = common constants dirs layout mondrian notify_osd shutil
|
||||||
|
|
115
usr/lib/byobu/include/layout
Executable file
115
usr/lib/byobu/include/layout
Executable file
|
@ -0,0 +1,115 @@
|
||||||
|
#!/bin/sh -e
|
||||||
|
#
|
||||||
|
# layout: save and restore byobu layouts
|
||||||
|
# Copyright (C) 2011 Dustin Kirkland <dustin.kirkland@gmail.com>
|
||||||
|
#
|
||||||
|
# Authors: Dustin Kirkland <dustin.kirkland@gmail.com>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, version 3 of the License.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
PKG="byobu"
|
||||||
|
[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc"
|
||||||
|
[ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX
|
||||||
|
. "${BYOBU_PREFIX}/lib/${PKG}/include/common"
|
||||||
|
|
||||||
|
# Get the layouts directory
|
||||||
|
DIR="$BYOBU_CONFIG_DIR/layouts"
|
||||||
|
mkdir -p "$DIR"
|
||||||
|
PRESETS="even-horizontal even-vertical main-horizontal main-vertical tiled"
|
||||||
|
current_panes=$(tmux list-panes | wc -l)
|
||||||
|
|
||||||
|
list_layouts() {
|
||||||
|
echo
|
||||||
|
echo "Restore layout with <shift-F8>, save a layout with <shift-ctrl-F8>"
|
||||||
|
echo
|
||||||
|
echo "Byobu Saved Layouts"
|
||||||
|
local count=0 i= desc= count= p=
|
||||||
|
for i in $PRESETS "$DIR"/*; do
|
||||||
|
desc=${i##*/}
|
||||||
|
count=$(expr $count + 1)
|
||||||
|
[ -f "$i" ] && p=$(head -n1 "$i")
|
||||||
|
[ -n "$p" ] && p=" ($p splits)"
|
||||||
|
echo " $count. $desc$p"
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
_RET="$count"
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
"save")
|
||||||
|
layout=$(tmux list-windows | grep "(active)$" | sed -e "s/.*\[layout //" -e "s/\] (active)$//")
|
||||||
|
panes=$(tmux list-panes | wc -l)
|
||||||
|
if [ -n "$2" ]; then
|
||||||
|
name="$2"
|
||||||
|
else
|
||||||
|
while true; do
|
||||||
|
list_layouts
|
||||||
|
echo -n "Enter a unique name to save this layout: "
|
||||||
|
name=$(head -n1)
|
||||||
|
valid=1
|
||||||
|
for i in $PRESETS "$DIR"/*; do
|
||||||
|
i=${i##*/}
|
||||||
|
if [ "$i" = "$name" ]; then
|
||||||
|
valid=0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
[ "$valid" = "1" ] && break
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
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
|
||||||
|
# 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
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# Create panes if nececessary to restore the layout
|
||||||
|
while [ $(tmux list-panes | wc -l) -lt $panes ]; do
|
||||||
|
tmux split-window
|
||||||
|
done
|
||||||
|
# Finally, restore the layout and refresh
|
||||||
|
tmux select-layout "$layout"
|
||||||
|
tmux source "$BYOBU_PREFIX/share/byobu/profiles/tmuxrc"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "ERROR: Invalid argument, try [save|restore]" 2>&1
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
|
@ -1,9 +1,9 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# byobu's tmux f-key keybindings
|
# byobu's tmux f-key keybindings
|
||||||
#
|
#
|
||||||
# Copyright (C) 2011 Dustin Kirkland
|
# Copyright (C) 2011 Dustin Kirkland <dustin.kirkland@gmail.com>
|
||||||
#
|
#
|
||||||
# Authors: Dustin Kirkland <kirkland@ubuntu.com>
|
# Authors: Dustin Kirkland <dustin.kirkland@gmail.com>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -60,6 +60,8 @@ bind-key -n M-NPage copy-mode \; send-keys NPage
|
||||||
bind-key -n M-PPage copy-mode \; send-keys PPage
|
bind-key -n M-PPage copy-mode \; send-keys PPage
|
||||||
bind-key -n F8 command-prompt -p "(rename-window)" "rename-window %%"
|
bind-key -n F8 command-prompt -p "(rename-window)" "rename-window %%"
|
||||||
bind-key -n C-F8 new-window -d "byobu-select-profile -r"
|
bind-key -n C-F8 new-window -d "byobu-select-profile -r"
|
||||||
|
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 S-F8 new-window -k "$BYOBU_PREFIX/lib/byobu/include/layout restore; clear; $SHELL"
|
||||||
bind-key -n F9 new-window -k -n config byobu-config
|
bind-key -n F9 new-window -k -n config byobu-config
|
||||||
bind-key -n M-F11 break-pane
|
bind-key -n M-F11 break-pane
|
||||||
bind-key -n C-F11 join-pane -h -s :. -t :-1
|
bind-key -n C-F11 join-pane -h -s :. -t :-1
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# disable byobu's tmux f-key keybindings
|
# disable byobu's tmux f-key keybindings
|
||||||
#
|
#
|
||||||
# Copyright (C) 2011 Dustin Kirkland
|
# Copyright (C) 2011 Dustin Kirkland <dustin.kirkland@gmail.com>
|
||||||
#
|
#
|
||||||
# Authors: Dustin Kirkland <kirkland@ubuntu.com>
|
# Authors: Dustin Kirkland <dustin.kirkland@gmail.com>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -56,6 +56,8 @@ unbind-key -n M-NPage
|
||||||
unbind-key -n M-PPage
|
unbind-key -n M-PPage
|
||||||
unbind-key -n F8
|
unbind-key -n F8
|
||||||
unbind-key -n C-F8
|
unbind-key -n C-F8
|
||||||
|
unbind-key -n C-S-F8
|
||||||
|
unbind-key -n S-F8
|
||||||
unbind-key -n F9
|
unbind-key -n F9
|
||||||
unbind-key -n M-F11
|
unbind-key -n M-F11
|
||||||
unbind-key -n C-F11
|
unbind-key -n C-F11
|
||||||
|
|
|
@ -26,6 +26,8 @@ and some convenient keybindings:
|
||||||
Alt-PageUp/PageDown Enter and move through scrollback
|
Alt-PageUp/PageDown Enter and move through scrollback
|
||||||
F8 Change the current window's name
|
F8 Change the current window's name
|
||||||
Ctrl-F8 Change status bar's color randomly
|
Ctrl-F8 Change status bar's color randomly
|
||||||
|
Shift-F8 Restore a split-pane layout
|
||||||
|
Ctrl-Shift-F8 Save the current split-pane layout
|
||||||
F9 Launch byobu-config window
|
F9 Launch byobu-config window
|
||||||
F10 * Used by X11 *
|
F10 * Used by X11 *
|
||||||
F11 * Used by X11 *
|
F11 * Used by X11 *
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue