Home > Software engineering >  Unbind all tmux prefix key
Unbind all tmux prefix key

Time:04-14

How can unbind default prefix key in tmux?

  • I mean the default set by the user, Not necessarily C-b

  • I do not know what the user has set! So I have to discover the prefix with the command

  • solution should be in the zsh file and not in .tmux.conf

  • use tmux command takes precedence over Regex

for getting default prefix key I use

$ tmux send-prefix
^[w

when I pipe send-prefix output to tmux unbind command, the output is as follows

$ tmux send-prefix | xargs tmux unbind
^[`missing key

if the command return M-q, I can unbind as following (but not return)

a_command | xargs tmux unbind

Other way is to use Regex for following output (but how?)

$ tmux list-keys | grep send-prefix
bind-key    -T prefix       M-q                  send-prefix

please help me...

CodePudding user response:

For example, in the .tmux.conf:

# remap prefix from CTRL-B to CTRL Spacebar                                                                                                           
set -g prefix C-Space                                                                                                                                     
unbind C-b

CodePudding user response:

Solved, by using awk!

$ tmux list-keys | grep send-prefix | awk '{print $4}' 
$ tmux list-keys | grep send-prefix | awk '{print $4}'

bind-key    -T prefix       M-q                  send-prefix

$ tmux list-keys | grep send-prefix | awk '{print $4}'
M-q

if have multi output we can iterate by piping to while

tmux list-keys | grep send-prefix | awk '{print $4}' |  while prefix_key line; do
    echo $prefix_key
    # tmux unbind $prefix_key
done
  • Related