mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-22 22:34:23 -07:00
byobu-ctrl-a: support taking an argument of 'screen' or 'emacs'
This commit is contained in:
parent
c6a24530c8
commit
91b7a8e07f
1 changed files with 30 additions and 7 deletions
|
@ -17,14 +17,31 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Usage() {
|
||||||
|
cat <<EOF
|
||||||
|
Usage: ${0##*/} [mode]
|
||||||
|
mode is one of 'screen' or 'emacs'
|
||||||
|
if not specified, prompt the user
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
PKG="byobu"
|
PKG="byobu"
|
||||||
[ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX
|
[ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX
|
||||||
. "${BYOBU_PREFIX}/lib/${PKG}/.common"
|
. "${BYOBU_PREFIX}/lib/${PKG}/.common"
|
||||||
|
|
||||||
|
bind_to=""
|
||||||
keybindings="$BYOBU_CONFIG_DIR/keybindings"
|
keybindings="$BYOBU_CONFIG_DIR/keybindings"
|
||||||
touch "$keybindings"
|
touch "$keybindings"
|
||||||
|
|
||||||
while true; do
|
case "${1}" in
|
||||||
|
-h|--help) Usage; exit 0;;
|
||||||
|
screen) bind_to="screen";;
|
||||||
|
emacs) bind_to="emacs";;
|
||||||
|
"") :;;
|
||||||
|
*) { Usage echo "bad argument $1"; } 1>&2; exit 1;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
while [ -z "$bind_to" ]; do
|
||||||
echo
|
echo
|
||||||
echo "Configure Byobu's ctrl-a behavior..."
|
echo "Configure Byobu's ctrl-a behavior..."
|
||||||
echo
|
echo
|
||||||
|
@ -41,13 +58,18 @@ while true; do
|
||||||
s=$(head -n1)
|
s=$(head -n1)
|
||||||
echo
|
echo
|
||||||
case "$s" in
|
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"
|
$SED -i -e "/^register a /d" -e "/^bindkey \"^A\"/d" -e "/^escape /d" "$keybindings"
|
||||||
echo 'bindkey "^A"' >> "$keybindings"
|
echo 'bindkey "^A"' >> "$keybindings"
|
||||||
echo "INFO: ctrl-a will now operate in emacs mode"
|
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"
|
$SED -i -e "/^register a /d" -e "/^bindkey \"^A\"/d" -e "/^escape /d" "$keybindings"
|
||||||
echo 'escape "^Aa"' >> "$keybindings"
|
echo 'escape "^Aa"' >> "$keybindings"
|
||||||
echo 'register x "^A"' >> "$keybindings"
|
echo 'register x "^A"' >> "$keybindings"
|
||||||
|
@ -55,8 +77,9 @@ while true; do
|
||||||
echo "INFO: ctrl-a will now operate in GNU Screen mode"
|
echo "INFO: ctrl-a will now operate in GNU Screen mode"
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
*) echo "Error: bad value for binding: $bind_to";;
|
||||||
done
|
esac
|
||||||
|
|
||||||
$BYOBU_BACKEND -X at 0 source "$BYOBU_CONFIG_DIR/profile"
|
$BYOBU_BACKEND -X at 0 source "$BYOBU_CONFIG_DIR/profile"
|
||||||
echo "To modify this behavior again later, run 'byobu-ctrl-a'"
|
echo "To modify this behavior again later, run 'byobu-ctrl-a'"
|
||||||
echo
|
echo
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue