From 9d6f74db73b3c35426260f2dbc9371f342edeae5 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Sun, 12 Feb 2012 10:53:12 -0600 Subject: [PATCH] * usr/bin/byobu-ctrl-a, usr/share/byobu/keybindings/f-keys.tmux, usr/share/byobu/keybindings/f-keys.tmux.disable, usr/share/byobu/profiles/tmuxrc: LP: #923134 - get byobu-ctrl-a working within tmux, like screen - prompt the user for ctrl-a to work in Screen/escape mode, or emacs mode --- debian/changelog | 6 +++ usr/bin/byobu-ctrl-a | 52 ++++++++++++------- usr/share/byobu/keybindings/f-keys.tmux | 4 +- .../byobu/keybindings/f-keys.tmux.disable | 1 + usr/share/byobu/profiles/tmuxrc | 1 + 5 files changed, 43 insertions(+), 21 deletions(-) diff --git a/debian/changelog b/debian/changelog index 048492fe..54b9a1f0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,12 @@ byobu (5.9) unreleased; urgency=low * usr/bin/byobu-status: - fix broken status expiration, which wasn't working and probably had a huge performance penalty :-( + * usr/bin/byobu-ctrl-a, usr/share/byobu/keybindings/f-keys.tmux, + usr/share/byobu/keybindings/f-keys.tmux.disable, + usr/share/byobu/profiles/tmuxrc: LP: #923134 + - get byobu-ctrl-a working within tmux, like screen + - prompt the user for ctrl-a to work in Screen/escape mode, or emacs + mode -- Dustin Kirkland Sun, 12 Feb 2012 10:01:36 -0600 diff --git a/usr/bin/byobu-ctrl-a b/usr/bin/byobu-ctrl-a index 8c4f8a47..21aed3a1 100755 --- a/usr/bin/byobu-ctrl-a +++ b/usr/bin/byobu-ctrl-a @@ -32,6 +32,7 @@ PKG="byobu" bind_to="" keybindings="$BYOBU_CONFIG_DIR/keybindings" +[ "$BYOBU_BACKEND" = "tmux" ] && keybindings="$keybindings.tmux" touch "$keybindings" # If the user has already chosen an escape sequence, then @@ -43,7 +44,7 @@ case "${1}" in screen) bind_to="screen";; emacs) bind_to="emacs";; "") :;; - *) { Usage echo "bad argument $1"; } 1>&2; exit 1;; + *) { Usage printf "%s\n" "Bad argument $1"; } 1>&2; exit 1;; esac while [ -z "$bind_to" ]; do @@ -55,7 +56,7 @@ while [ -z "$bind_to" ]; do echo " (2) Emacs mode (go to beginning of line)" echo echo "Note that:" - echo " - F12 also operates as Screen escape in Byobu" + echo " - F12 also operates as an escape in Byobu" echo " - You can press F9 and choose your escape character" echo " - You can run 'byobu-ctrl-a' at any time to change your selection" echo @@ -70,34 +71,45 @@ done case "$bind_to" in emacs) - $BYOBU_SED -i -e "/^register a /d" -e "/^bindkey \"^A\"/d" -e "/^escape escape \^Aa/d" "$keybindings" - echo 'bindkey "^A"' >> "$keybindings" + case "$BYOBU_BACKEND" in + screen) + $BYOBU_SED -i -e "/^register a /d" -e "/^bindkey \"^A\"/d" -e "/^escape escape \^Aa/d" "$keybindings" + echo 'bindkey "^A"' >> "$keybindings" + $BYOBU_BACKEND -X at 0 source "$BYOBU_CONFIG_DIR/profile" + ;; + tmux) + $BYOBU_SED -i -e "/^set -g prefix /d" -e "/ send-prefix/d" -e "/^unbind-key -n C-a/d" "$keybindings" + echo "set -g prefix F12" >> "$keybindings" + echo "unbind-key -n C-a" >> "$keybindings" + $BYOBU_BACKEND source "$BYOBU_PREFIX/share/byobu/profiles/tmuxrc" + ;; + esac echo "INFO: ctrl-a will now operate in emacs mode" - echo > "$keybindings.tmux" ;; screen) - $BYOBU_SED -i -e "/^register a /d" -e "/^bindkey \"^A\"/d" -e "/^escape /d" "$keybindings" - echo 'escape "^Aa"' >> "$keybindings" - echo 'register x "^A"' >> "$keybindings" - echo 'bindkey "^A"' >> "$keybindings" - echo "source /usr/share/doc/tmux/examples/screen-keys.conf" > "$keybindings.tmux" + case "$BYOBU_BACKEND" in + screen) + $BYOBU_SED -i -e "/^register a /d" -e "/^bindkey \"^A\"/d" -e "/^escape /d" "$keybindings" + echo 'escape "^Aa"' >> "$keybindings" + echo 'register a "^A"' >> "$keybindings" + echo 'bindkey "^A"' >> "$keybindings" + $BYOBU_BACKEND -X at 0 source "$BYOBU_CONFIG_DIR/profile" + ;; + tmux) + $BYOBU_SED -i -e "/^set -g prefix /d" -e "/ send-prefix/d" -e "/^unbind-key -n C-a/d" "$keybindings" + echo "unbind-key -n C-a" >> "$keybindings" + echo "set -g prefix ^A,F12" >> "$keybindings" + echo "bind a send-prefix" >> "$keybindings" + $BYOBU_BACKEND source "$BYOBU_PREFIX/share/byobu/profiles/tmuxrc" + ;; + esac echo "INFO: ctrl-a will now operate in GNU Screen mode" - break ;; *) echo "Error: bad value for binding: $bind_to" ;; esac -case "$BYOBU_BACKEND" in - tmux) - true - ;; - screen) - $BYOBU_BACKEND -X at 0 source "$BYOBU_CONFIG_DIR/profile" - ;; -esac - echo "To modify this behavior again later, run 'byobu-ctrl-a'" echo diff --git a/usr/share/byobu/keybindings/f-keys.tmux b/usr/share/byobu/keybindings/f-keys.tmux index a060bbf0..694c7f85 100644 --- a/usr/share/byobu/keybindings/f-keys.tmux +++ b/usr/share/byobu/keybindings/f-keys.tmux @@ -19,7 +19,7 @@ ############################################################################### # Add F12 to the prefix list -set -g prefix ^A,F12 +set -g prefix F12 # Byobu's Keybindings # Documented in: $BYOBU_PREFIX/share/doc/byobu/help.tmux.txt @@ -70,3 +70,5 @@ bind-key -n S-F11 join-pane -v -s :. -t :-1 bind-key -n S-F12 source $BYOBU_PREFIX/share/byobu/keybindings/f-keys.tmux.disable bind-key -n C-S-F12 new-window $BYOBU_PREFIX/lib/byobu/include/mondrian bind-key -n M-IC paste-buffer + +bind-key -n C-a new-window -n "ctrl-a" "byobu-ctrl-a" diff --git a/usr/share/byobu/keybindings/f-keys.tmux.disable b/usr/share/byobu/keybindings/f-keys.tmux.disable index b1c75998..65b8e0d8 100644 --- a/usr/share/byobu/keybindings/f-keys.tmux.disable +++ b/usr/share/byobu/keybindings/f-keys.tmux.disable @@ -66,3 +66,4 @@ unbind-key -n S-F11 bind-key -n S-F12 source $BYOBU_PREFIX/share/byobu/keybindings/f-keys.tmux unbind-key -n C-S-F12 unbind-key -n M-IC +unbind-key -n C-a diff --git a/usr/share/byobu/profiles/tmuxrc b/usr/share/byobu/profiles/tmuxrc index d502ffe8..9bf7f9ba 100644 --- a/usr/share/byobu/profiles/tmuxrc +++ b/usr/share/byobu/profiles/tmuxrc @@ -24,4 +24,5 @@ source-file $HOME/.byobu/color.tmux source-file $BYOBU_CONFIG_DIR/profile.tmux +source-file $BYOBU_CONFIG_DIR/keybindings.tmux source-file $HOME/.byoburc.tmux