好像已经开放了关于这个问题的错误 https://bugs.launchpad.net/byobu/+bug/482623.
我能够将 iTerm2 配置为在 OS X 上本地使用 byobu,以及在 Ubuntu 14.04 服务器上通过 ssh 远程使用 byobu。
Using:
- OS X 版本:10.9.5 内部版本 13F34
- iTerm2版本:Build 1.0.0.20140629
First, in your OS X system preferences, edit your keyboard settings and remove or change any shortcut settings that may conflict with byobu (i.e. Ctrl + F1-F12).
选项 1:使用转义序列的解决方法
Here's a workaround that will work without adding full functionality to the FN keys. This will allow you to split windows vertically using the byobu escape key:
Start byobu
.
Set your desired Ctrl-A behavior by running: byobu-ctrl-a
. I chose to go with Emacs-mode.
Run byobu-config
and choose or change your escape sequence. I went with the new default Ctrl + S. The F12 key is also an escape sequence
Now you can issue a command with your escape sequence. Try F12 then % or Ctrl + s then % to split a window vertically. For a full list of commands, try Ctrl + s then ? or F12 then ?.
Option 2: Setting iTerm2 key mappings to fully use all FN keys.
You can add some key mappings to your iTerm2 profile to get the CTRL, ALT, SHIFT, and FN keys to work with byobu. This is tedious, but I went through the exercise and it seems to work. I don't think there's an automated way to save these key mappings with iTerm2.
- 打开 iTerm2 首选项并选择配置文件。
- 选择您想要使用的配置文件。
- 打开“终端”窗格,然后在“报告终端类型”下选择“linux”。
-
打开“按键”窗格并手动添加以下按键绑定。以下是如何添加一键绑定的示例:
- 单击“+”图标。
- 输入在第一个字段中映射的键盘快捷键。例子:
CTRL + F2
- 在“操作”字段中选择“发送转义序列”。
- 在第三个字段中输入字符。例子:
[1;5Q
您可以通过参考来确定此处未列出的任何键序列的控制字符tmux 源代码 https://github.com/tmux/tmux/blob/master/xterm-keys.c.
对所有这些映射重复此操作以使相应的 byobu 命令起作用:
-
CTRL + F2 :
[1;5Q
-
CTRL + SHIFT + F2 :
[1;6Q
-
ALT + LEFT :
[1;3D
-
ALT + RIGHT :
[1;3C
-
ALT + UP :
[1;3A
-
ALT + DOWN :
[1;3B
-
CTRL + F3 :
[1;5R
-
CTRL + F4 :
[1;5S
-
CTRL + SHIFT + F3 :
[1;6R
-
CTRL + SHIFT + F4 :
[1;6S
-
SHIFT + ALT + LEFT :
[1;4D
-
SHIFT + ALT + RIGHT :
[1;4C
-
SHIFT + ALT + UP :
[1;4A
-
SHIFT + ALT + DOWN :
[1;4B
-
CTRL + F5 :
[15;5~
-
CTRL + SHIFT + F5 :
[15;6~
-
ALT + F6 :
[17;3~
-
CTRL + F6 :
[17;5~
-
ALT + PPAGE :
[5;3~
-
ALT + NPAGE :
[6;3~
-
CTRL + F8 :
[19;5~
-
ALT + SHIFT + F8 :
[19;4~
-
CTRL + SHIFT + F8 :
[19;6~
-
CTRL + F9 :
[20;5~
-
ALT + F11 :
[23;3~
-
CTRL + F11 :
[23;5~
-
ALT + F12 :
[24;3~
-
CTRL + F12 :
[24;5~
-
ALT + INS:
[2;3~
Summary
为了让事情顺利进行,我们需要:
- 消除与 OS X 键盘快捷键的冲突。
- 编辑终端键映射以在使用功能键时发送正确的转义序列。
- 将 iTerm2 终端类型设置为“Linux”,这会将 TERM 环境变量设置为“linux”。 Byobu 和/或 Tmux 似乎对此很敏感。
关于转义序列的其他一些参考:SO link https://stackoverflow.com/questions/19062315/how-do-i-find-out-what-escape-sequence-my-terminal-needs-to-send and xterm-keys.c https://github.com/tmux/tmux/blob/master/xterm-keys.c
新窗口和窗格的默认目录
看起来 tmux 1.8 和 tmux 1.9 之间的 tmux 窗口默认目录存在一些差异(Src http://sourceforge.net/p/tmux/mailman/tmux-users/thread/20131019080624.GA13382@SUNGPAE/, Src https://unix.stackexchange.com/questions/12032/create-new-window-with-current-directory-in-tmux, Src https://news.ycombinator.com/item?id=7275911)。如果您将 byobu 与 tmux 1.9 一起使用,您可以尝试将其添加到您的~/.byobu/keybindings.tmux
文件,以便当您创建新窗口或垂直/水平分割时,它们会在与当前窗格相同的目录中打开:
unbind-key -n F2
bind-key -n F2 display-panes \; new-window -c "#{pane_current_path}" -n -
unbind-key -n C-F2
bind-key -n C-F2 display-panes \; split-window -hc "#{pane_current_path}"
unbind-key -n S-F2
bind-key -n S-F2 display-panes \; split-window -vc "#{pane_current_path}"
unbind-key %
bind-key % display-panes \; split-window -hc "#{pane_current_path}"
unbind-key |
bind-key | display-panes \; split-window -vc "#{pane_current_path}"
Press F5 to reload settings.