From 91b7a8e07f04e6b32bd9a36ad12ebe994edaed40 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 20 Jul 2011 14:40:36 -0400 Subject: [PATCH] byobu-ctrl-a: support taking an argument of 'screen' or 'emacs' --- usr/bin/byobu-ctrl-a | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/usr/bin/byobu-ctrl-a b/usr/bin/byobu-ctrl-a index 8f423b22..30ece658 100755 --- a/usr/bin/byobu-ctrl-a +++ b/usr/bin/byobu-ctrl-a @@ -17,14 +17,31 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +Usage() { + cat <&2; exit 1;; +esac + +while [ -z "$bind_to" ]; do echo echo "Configure Byobu's ctrl-a behavior..." echo @@ -41,13 +58,18 @@ while true; do s=$(head -n1) echo case "$s" in - 1) + 1) bind_to="emacs"; break;; + 2) bind_to="screen"; break;; + esac +done + +case "$bind_to" in + emacs) $SED -i -e "/^register a /d" -e "/^bindkey \"^A\"/d" -e "/^escape /d" "$keybindings" echo 'bindkey "^A"' >> "$keybindings" echo "INFO: ctrl-a will now operate in emacs mode" - break - ;; - 2) + ;; + screen) $SED -i -e "/^register a /d" -e "/^bindkey \"^A\"/d" -e "/^escape /d" "$keybindings" echo 'escape "^Aa"' >> "$keybindings" echo 'register x "^A"' >> "$keybindings" @@ -55,8 +77,9 @@ while true; do echo "INFO: ctrl-a will now operate in GNU Screen mode" break ;; - esac -done + *) echo "Error: bad value for binding: $bind_to";; +esac + $BYOBU_BACKEND -X at 0 source "$BYOBU_CONFIG_DIR/profile" echo "To modify this behavior again later, run 'byobu-ctrl-a'" echo