One nice feature of screen is its ability to assign keyboard shortcuts to groups called "classes". With bind -c
, you could assign that shortcuts to a particular class, and binding command -c
to a key allowed you to select that class. This allowed multi-tier keyboard shortcuts. For example, I used the x
key to select a class dedicated common commands. By having these launcher shortcuts in their own class, it is possible to use mnemonic keys without worrying about conflicts with the normal set of key-bindings. Is there any way to replicate this feature in tmux
?
Example
# from my .screenrc
bind -c execute o screen -t imap 10 offlineimap.sh -o
bind -c execute m screen -t mpd ncmpcpp
bind -c execute w screen -t vw vimwiki
# ... more application launchers
bind x command -c execute
Usage: prefixx enters the launcher key class, where I put all my application keyboard shortcuts.
Answer
After understanding better what you are trying to do, I think a short bash script is the best way to go (sorry, I don't think a tmux
-only solution similar to screen
command classes exists):
In .tmux.conf
:
bind-key x command-prompt -p "launch what?" " "run-shell \"tmux-launcher %%\""
tmux-launcher
should be an executable shell script somewhere in your path:
#!/bin/bash
case $1 in
o) tmux new-window -n imap -t 10 offlineimap.sh -o ;;
m) tmux new-window -n mod ncmpcpp ;;
w) tmux new-window -n vw vimwiki ;;
esac
One drawback is that you must type return after the letter that selects the window to create.
No comments:
Post a Comment