OS X Byobu Vertical Split - macos

I'm currently on OS X using iTerm2 and byobu, and I can't figure out how to split my screen vertically on OS X. On Linux, I can split my screen vertically with Ctrl+F2, but on OSX, that doesn't work, thanks to Apple's different keyboard.
I Googled all around for the solution, and I can't figure this out. I can split my screen horizontally with Shift+F2, but I need to be able to split vertically. Has anyone figured out how to get byobu's keyboard bindings to work well with Apple computers?
Thanks in advance.

Looks like there's on open bug on this issue.
I was able to configure iTerm2 to use byobu locally on OS X as well as remotely over ssh on an Ubuntu 14.04 server.
Using:
OS X version: 10.9.5 Build 13F34
iTerm2 version: 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).
Option 1: Workaround using escape sequences
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.
Open iTerm2 preference and select Profiles.
Choose the profile you'd like to use.
Open the Terminal pane and under "Report terminal type" choose "linux".
Open the Keys pane and manually add the following key bindings. Here's an example how to add one key binding:
Click the '+' icon.
Enter the keyboard shortcut being mapped in the first field. Example: CTRL + F2
Select "Send Escape Sequence" in the Action field.
Enter the characters in the third field. Example: [1;5Q
You can determine the control characters for any key sequence not listed here by referring to the tmux source code.
Repeat this for all of these mappings to make the corresponding byobu command work:
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
To get things to work we needed to:
Remove conflicts with OS X keyboard shortcuts.
Edit the terminal key mappings to send the correct escape sequences when using function keys.
Set the iTerm2 terminal type to "Linux", which sets the TERM environmental variable to be "linux". Byobu and/or Tmux seemed to be sensitive to this.
Some other references on escape sequences: SO link and xterm-keys.c
Default directory for new windows and panes
It looks like there are some difference in tmux window default directory between tmux 1.8 and tmux 1.9 (Src, Src, Src). If you are using byobu with tmux 1.9 you can try adding this to your ~/.byobu/keybindings.tmux file so that when you create new windows or vertical/horizontal splits that they open in the same directory as the current pane:
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.

Related

tmux prefix key not working on mac OS High Sierra

I installed tmux (3.1c) with Homebrew and when I type C-b ? I get the message
-bash: C-b: command not found
but when I press ctrl + b and ? it works. I also ran
tmux show-options -g | grep prefix
which displays
prefix C-b
prefix2 Invalid#1fff00000000
what am I doing wrong?
It sounds like you literally typing Shiftc-bShift/
C-b is another way of writing ctrl + b - they both mean the Ctrlb keys. Typing Shiftc-b will not trigger any tmux commands; this is by design.
but when I press ctrl + b and ? it works
That is the expected behavior. If that is not your goal, you should edit your question.

Byobu Shift + F2 not working on windows

Connecting to byobu in Ubuntu 16.04.3 LTS on a Windows 10 system, when I type Shift+F2 to get a vertical split, nothing happens. Typing plain F2 works and opens a new window. Ctrl + F2 works too and splits vertically.
I tried all the terminal keyboard types in PuTTY/Kitty/ConEmu configuration (ex. XTerm R2, Linux) without any luck. Any ideas? Is there any another keyboard shortcut to do the same thing?
How about using the Ctrl + A commands which is what I use mostly.
Ctrl + A then | will give you a horizontal split
Ctrl + A then % will give you a vertical split

how to delete entire line in sublime in windows

I have to use window based computer, i usually could delete a whole line using cmd + backspace in mac. Is it possible to do the same in windows without doing:
shift+home and then backspace.
CTRL + SHIFT + K will delete a line in Sublime Text 3 on Windows.
By default it is
CTRL+SHIFT+K
which to me doesn't feel very comfortable.
If you want to use a custom shortcut instead:
Go to Preferences › Key Bindings,
On the right side (the user defined keymap), add this line:
{ "keys": ["ctrl+d"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} }
Save.
Now you can use CTRL+D as the delete line command!
CTRL + SHIFT + K will delete a line in Sublime Text 3 on Linux(tested on Ubuntu 14.0), too.
Command + X will work for Mac computers.
EDIT: but it will also "cut" the line. So you may lose your clipboard content.
CTRL + SHIFT + K will delete a line in Sublime Text 3 on Mac OS, too.
CTRL + X will do the job for you.
Ctrl + X = Cut Line
Ctrl + Shift + K = Delete Line

Binding option left and right arrows to move by words in zsh command line

I'm using iTerm2 on Mac OSX 10.8 with an xterm key binding and zsh.
I'd like zsh to use option left arrow and option right arrow to do the standard Mac bindings of left and right word.
If I hit ctrl-v then option-left and right arrows, where are the two key sequences that print:
^[[1;9D
^[[1;9C
I tried using binding these sequences using bindkey -v, but with no luck.
You can configure iTerm2 to do this like so:
Go to iTerm2 > Preferences > Profiles > Keys
If there is already an ⌥ ← or ⌥ → setting, delete it by selecting it and hitting -.
Add a new shortcut by hitting the + button.
Type ⌥+← in the Keyboard shortcut box.
Select Send Escape Sequence in the Action box.
Enter b for Characters to send.
Click Ok.
Repeat the above procedure for ⌥ →, this time entering f for the Characters to send.
Taken from this great tutorial which describes the whole process in detail and with pictures:
Use ⌥ ← and ⌥ → to jump forwards / backwards words in iTerm 2, on OS X | Coderwall
Add the following to .zshrc
# Skip forward/back a word with opt-arrow
bindkey '[C' forward-word
bindkey '[D' backward-word
If you're looking to easily add this and a bundle of similar mappings, there's a "Natural Text Editing" preset under Preferences > Profiles > Keys (version 3):
Simply add these to your .zshrc
bindkey "\e[1;3D" backward-word # ⌥←
bindkey "\e[1;3C" forward-word # ⌥→
bindkey "^[[1;9D" beginning-of-line # cmd+←
bindkey "^[[1;9C" end-of-line # cmd+→
It works for me using kitty

For the Vim editor, how do I map a function key in .vimrc on Mac OS X?

I'm trying to map f11 to a command within vim, with a line in .vimrc such as:
map <F11> :exe '!ctags -R --python-kinds=-i -f ./tags ' . shellescape(system('python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"'))<CR>
But if you hit F11 it just turns up the volume. Is it possible to remap keys that have
OS-wide functions in OSX?
I don't want to remap any more commonly used key here because regenerating tags takes awhile.
You have two options that I know of:
1) Enable the regular use of the function keys, ie. f1 - f12 no longer executes the OSX specific command such as decrease volume. Instead you will have to hold the fn key press the f key. I have this set up on my computer and I've successfully mapped the function keys in Vim / MacVim. To do this go to System preferences --> Keyboard and check of the Use all F1, F2,...
2) Use fn + F11 to execute the command.
6 years later...
Check out https://github.com/Pyroh/Fluor/releases
It allows you to change the behavior of the function keys based on the app that is currently active.

Resources