* usr/bin/byobu-config, usr/bin/byobu-ctrl-a:

- fix escape sequence setting in config with tmux
This commit is contained in:
Dustin Kirkland 2012-09-16 23:07:35 -05:00
commit 83f8c14d9d
3 changed files with 32 additions and 31 deletions

3
debian/changelog vendored
View file

@ -1,6 +1,7 @@
byobu (5.22) unreleased; urgency=low
* UNRELEASED
* usr/bin/byobu-config, usr/bin/byobu-ctrl-a:
- fix escape sequence setting in config with tmux
-- Dustin Kirkland <kirkland@ubuntu.com> Wed, 11 Jul 2012 12:02:34 -0500

View file

@ -238,10 +238,14 @@ def appendtofile(p, s):
return
def getesckey():
path=BYOBU_CONFIG_DIR+'/keybindings'
if BYOBU_BACKEND == "tmux":
path=BYOBU_CONFIG_DIR+'/keybindings.tmux'
line = commands.getoutput("grep '^set -g prefix ' "+path)
else:
path=BYOBU_CONFIG_DIR+'/keybindings'
line = commands.getoutput("grep ^escape "+path)
if not os.path.exists(path):
return DEF_ESC
line = commands.getoutput("grep ^escape "+path)
if line == "":
return DEF_ESC
esc = line[line.find('^')+1]
@ -250,20 +254,8 @@ def getesckey():
return esc
def setesckey(key):
path = BYOBU_CONFIG_DIR+'/keybindings'
if key != "":
if key == " ":
key = "`"
u = key[0].upper()
l = key[0].lower()
if os.path.exists(path):
out = commands.getoutput(BYOBU_SED+" -i -e 's/^escape.*$//' "+path)
appendtofile(path, "escape ^"+u+l+"\n")
out = commands.getoutput(BYOBU_SED+" -i -e 's/^register.*$//' "+path)
out = commands.getoutput("grep -sh '^register x' "+SHARE+"/keybindings/*keys")
appendtofile(path, out+"\n")
out = commands.getoutput(BYOBU_SED+" -i -e 's/\"^^/\"\^"+l+"/g' "+path)
out = commands.getoutput(BYOBU_SED+" -i -e '/^$/d' "+path)
if key.isalpha():
out = commands.getoutput("byobu-ctrl-a screen %s" % key)
def chgesc(snackScreen, size):
esc=Entry(2, text=getesckey(), returnExit=1)

View file

@ -47,6 +47,14 @@ case "${1}" in
*) { Usage printf "%s\n" "Bad argument $1"; } 1>&2; exit 1;;
esac
if [ "${2}" ]; then
KEY=$(printf "$2" | $BYOBU_SED 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/')
key=$(printf "$2" | $BYOBU_SED 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')
else
KEY="A"
key="a"
fi
while [ -z "$bind_to" ]; do
echo
echo "Configure Byobu's ctrl-a behavior..."
@ -73,14 +81,14 @@ case "$bind_to" in
emacs)
case "$BYOBU_BACKEND" in
screen)
$BYOBU_SED -i -e "/^register x /d" -e "/^bindkey \"^A\"/d" -e "/^escape escape \^Aa/d" "$keybindings"
echo 'bindkey "^A"' >> "$keybindings"
$BYOBU_SED -i -e "/^register x /d" -e "/^bindkey \"^\"/d" -e "/^escape escape \^${KEY$}${key}/d" "$keybindings"
echo 'bindkey "^${KEY}"' >> "$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"
$BYOBU_SED -i -e "/^set -g prefix/d" -e "/ send-prefix/d" -e "/^unbind-key -n C-${key}/d" "$keybindings"
echo "set -g prefix F12" >> "$keybindings"
echo "unbind-key -n C-a" >> "$keybindings"
echo "unbind-key -n C-${key}" >> "$keybindings"
$BYOBU_BACKEND source "$BYOBU_PREFIX/share/byobu/profiles/tmuxrc"
;;
esac
@ -89,24 +97,24 @@ case "$bind_to" in
screen)
case "$BYOBU_BACKEND" in
screen)
$BYOBU_SED -i -e "/^register x /d" -e "/^bindkey \"^A\"/d" -e "/^escape /d" "$keybindings"
echo 'escape "^Aa"' >> "$keybindings"
echo 'register x "^A"' >> "$keybindings"
echo 'bindkey "^A"' >> "$keybindings"
$BYOBU_SED -i -e "/^register x /d" -e "/^bindkey \"^\"/d" -e "/^escape /d" "$keybindings"
echo 'escape "^${KEY}${key}"' >> "$keybindings"
echo 'register x "^${KEY}"' >> "$keybindings"
echo 'bindkey "^${KEY}"' >> "$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"
$BYOBU_SED -i -e "/^set -g prefix/d" -e "/ send-prefix/d" -e "/^unbind-key -n C-${key}/d" "$keybindings"
echo "unbind-key -n C-${key}" >> "$keybindings"
if $BYOBU_BACKEND -V | grep " 1.5"; then
# tmux 1.5 supports a list of prefixes
echo "set -g prefix ^A,F12" >> "$keybindings"
echo "set -g prefix ^${KEY},F12" >> "$keybindings"
else
# tmux 1.6 and above supports prefix and prefix2
echo "set -g prefix ^A" >> "$keybindings"
echo "set -g prefix2 ^A" >> "$keybindings"
echo "set -g prefix ^${KEY}" >> "$keybindings"
echo "set -g prefix2 ^${KEY}" >> "$keybindings"
fi
echo "bind a send-prefix" >> "$keybindings"
echo "bind ${key} send-prefix" >> "$keybindings"
$BYOBU_BACKEND source "$BYOBU_PREFIX/share/byobu/profiles/tmuxrc"
;;
esac