Skip to content

Lock away your tmux keybinds temporarely.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

TheSast/tmux-keylocker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tmux Keylocker

This tmux tpm plugin allows you to lock your keybinds away for a while, until you need to use them again

Usage

Either use the configured bindings or run tmux toggle-mappings in you terminal to lock away all (other) bindings until you run it again. You can use tmux lock-mappings and tmux unlock-mappings if you want to separate those behaviours.

Installation

You can install this plugin through tpm:

  1. Install tpm (duh)
  2. Add this line to your tmux.conf:
set -g @plugin 'thesast/tmux-keylocker'
  1. Install the plugin with <prefix>I, unless you changed @tpm-install, in which case you should use the keybind you set.

Configuration

This plugins offers three options to be set in your tmux.conf with these defaults:

set -g @keylocker-toggle-bind 'C-g'
set -g @keylocker-lock-bind 'None'
set -g @keylocker-unlock-bind 'None'

to remove the pre-set binding set the related option option to None.

Note that these are a simple wrapper binds over the command aliases provided by the plugin.

You may also want to set your status bar to show whether or not your mappings are currently locked using the tmux option set by this plugin. @keylocker-status will contain either the path to the file where the currently locked mappings are stored or 0.

Here are some examples with and without using a script:

set -g status-right "#{?@keylocker-status,#[fg=color255]#[bg=color208] LOCKED ,#[fg=color0]#[bg=color101] UNLOCKED }"

img/status-simple-locked.png img/status-unlocked.png

set -g status-right "#(~/.config/tmux/scripts/status/keylocker.bash)"
#!/usr/bin/env bash
# script located in ~/.config/tmux/scripts/status/keylocker.bash
MAPPINGS="$(tmux show-option -gqv "@keylocker-status")"
[ "$MAPPINGS" = "0" ] &&
  echo "#[fg=color0]#[bg=color101] UNLOCKED " ||
  echo "#[fg=color255]#[bg=color208] LOCKED $(cat $MAPPINGS | wc -l) MAPPINGS "

img/status-script-locked.png

Other plugins

You might also like these plugins:

Licence

MIT and Apache 2.0