diff --git a/README.md b/README.md index 710fdc7..15a1eb5 100644 --- a/README.md +++ b/README.md @@ -93,25 +93,42 @@ Turn it on by setting `tmux: true` in `terminalle.yaml` (see [configuration][10] The following shortcuts are enabled in tmux mode: -| tmux default | tmux mode | Command | -| -----------: | --------: | :------------------------- | -| ` "` | `Ctrl+"` | `split-window` | -| ` %` | `Ctrl+%` | `split-window -h` | -| ` {` | `Ctrl+{` | `swap-pane -U` | -| ` }` | `Ctrl+}` | `swap-pane -D` | -| ` [` | `Ctrl+[` | `copy-mode` | -| ` ]` | `Ctrl+]` | `paste-buffer` | +| tmux mode | tmux default | Command | +| --------: | -----------: | :------------------------------------------------------------------ | +| `Ctrl+!` | ` !` | `break-pane` | +| `Ctrl+"` | ` "` | `split-window` | +| `Ctrl+#` | ` #` | `list-buffers` | +| `Ctrl+$` | ` $` | `command-prompt -I "#S" "rename-session -- '%%'"` | +| `Ctrl+%` | ` %` | `split-window -h` | +| `Ctrl+&` | ` &` | `confirm-before -p "kill-window #W? (y/n)" kill-window` | +| `Ctrl+'` | ` '` | `command-prompt -T window-target -p "index" "select-window -t ':%%'"` | +| `Ctrl+(` | ` (` | `switch-client -p` | +| `Ctrl+)` | ` )` | `switch-client -n` | +| `Ctrl+,` | ` ,` | `command-prompt -I "#W" "rename-window -- '%%'"` | +| `Ctrl+:` | ` :` | `command-prompt` | +| `Ctrl+;` | ` ;` | `last-pane` | +| `Ctrl+=` | ` =` | `choose-buffer -Z` | +| `Ctrl+[` | ` [` | `copy-mode` | +| `Ctrl+]` | ` ]` | `paste-buffer` | +| `Ctrl+{` | ` {` | `swap-pane -U` | +| `Ctrl+}` | ` }` | `swap-pane -D` | To reap maximum benefits, add the following to your `.tmux.conf`, taking care of other common tmux shortcuts that do not get mangled by typical terminal emulators: ```bash -# Generally shorten `Ctrl+b ` to `Ctrl+` for various ``. -# Note that `new-window` is not shortened because `Ctrl+c` should send `SIGINT`. +# Generally shorten ` ` to `Ctrl+` for various ``. +# Note that some commands (e.g. ` c` for `new-window`) would conflict with +# established control sequences (`Ctrl+c` should send `SIGINT`) if shortened. +bind -n C-f command-prompt "find-window -Z -- '%%'" bind -n C-n next-window +bind -n C-o select-pane -t ":.+" bind -n C-p previous-window +bind -n C-q display-panes +bind -n C-s choose-tree -Zs +bind -n C-t clock-mode +bind -n C-x confirm-before -p "kill-pane #P? (y/n)" kill-pane bind -n C-Space next-layout -bind -n C-x confirm-before -p 'kill-pane #P? (y/n)' kill-pane # Resize panes using arrow keys and either `Ctrl` or `Meta`. bind -n C-Up resize-pane -U diff --git a/terminalle.1 b/terminalle.1 index f442222..7d2884c 100644 --- a/terminalle.1 +++ b/terminalle.1 @@ -1,4 +1,4 @@ -.TH terminalle 1 "2021-10-03" "v0.6" +.TH terminalle 1 "2021-10-03" "v0.7" .SH NAME Terminalle diff --git a/terminalle.yaml b/terminalle.yaml index 1c1e26e..091733b 100644 --- a/terminalle.yaml +++ b/terminalle.yaml @@ -20,12 +20,5 @@ colors: - '#93a1a1' # bright cyan - '#fdf6e3' # bright white opacity: 0.75 -# If enabled, the `tmux` option hardwires the following tmux shortcuts -# since it is impossible to bind them from `.tmux.conf`: -# Ctrl+" -> split-window -# Ctrl+% -> split-window -h -# Ctrl+{ -> swap-pane -U -# Ctrl+} -> swap-pane -D -# Ctrl+[ -> copy-mode -# Ctrl+] -> paste-buffer +# See the readme for an explanation of the `tmux` option. tmux: true diff --git a/terminalle/__init__.py b/terminalle/__init__.py index 8dd06a7..346e960 100644 --- a/terminalle/__init__.py +++ b/terminalle/__init__.py @@ -2,4 +2,4 @@ from .terminalle import Terminalle from .settings import load as load_settings -__version__ = '0.6' +__version__ = '0.7' diff --git a/terminalle/terminalle.py b/terminalle/terminalle.py index 4f65ead..d56e78f 100644 --- a/terminalle/terminalle.py +++ b/terminalle/terminalle.py @@ -26,6 +26,30 @@ ''' +# https://github.com/tmux/tmux/blob/28b6237c623f507188a782a016563c78dd0ffb85/key-bindings.c#L344 +# https://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h +_default_tmux_commands = [ + ('exclam', 'break-pane'), + ('quotedbl', 'split-window'), + ('numbersign', 'list-buffers'), + ('dollar', 'command-prompt -I "#S" "rename-session -- '"'"'%%'"'"'"'), + ('percent', 'split-window -h'), + ('ampersand', 'confirm-before -p "kill-window #W? (y/n)" kill-window'), + ('apostrophe', 'command-prompt -T window-target -p "index" "select-window -t '"'"':%%'"'"'"'), + ('parenleft', 'switch-client -p'), + ('parenright', 'switch-client -n'), + ('comma', 'command-prompt -I "#W" "rename-window -- '"'"'%%'"'"'"'), + # ('minus', 'delete-buffer'), + # ('period', 'command-prompt -T target "move-window -t '"'"'%%'"'"'"'), + ('colon', 'command-prompt'), + ('semicolon', 'last-pane'), + ('equal', 'choose-buffer -Z'), + ('bracketleft', 'copy-mode'), + ('bracketright', 'paste-buffer'), + ('braceleft', 'swap-pane -U'), + ('braceright', 'swap-pane -D'), +] + class Terminalle: """ Manages the D-Bus service and the terminal window. """ @@ -61,12 +85,7 @@ def __init__(self, settings: Dict[str, object], show: bool): _init_ctrl_shift_handler('v', window, accel_group, self._paste_clipboard) if settings['tmux']: # Hardwire shortcuts that are generally impossible to configure in `.tmux.conf`. - for key_name, cmd in [('quotedbl', 'split-window'), - ('percent', 'split-window -h'), - ('braceleft', 'swap-pane -U'), - ('braceright', 'swap-pane -D'), - ('bracketleft', 'copy-mode'), - ('bracketright', 'paste-buffer')]: + for key_name, cmd in _default_tmux_commands: _init_ctrl_handler(key_name, window, accel_group, _tmux_cmd(cmd)) window.add_accel_group(accel_group)