The original code base on tmux-text-macros, and @manesec made a lot of changes.
The original idea was to integrate some of the more useful tools for my tmux functionality, hence the name tmux-command-macros
.
既然找不到想要的工具,那也只能自己写了。 QAQ
Since I have to do repetitive commands all the time, which bores me to death, I was looking for a macros on tmux. But, Unfortunately, there were no good plugins to be found, so I decided to make my own.
tmux-command-macros
is a tmux plugin. It let's you define a bunch of macros, from which you can choose by pressing Prefix + /
.
By default it contains a demo script.
Imagine you're a hacker.
Note: We don't provide any scripts, if interested just look at my other project.
Note: Current are not support to recording the macros.
fzf
jq
- clone repository to
~/.tmux/plugins/
, change premission - add
run-shell ~/.tmux/plugins/tmux-command-macros/tmux-command-macros
to your~/.tmux.conf
- run
tmux source ~/.tmux.conf
to enable the changes
# step 1
sudo apt install -y fzf jq
git clone https://github.com/manesec/tmux-command-macros.git ~/.tmux/plugins/tmux-command-macros
chmod +x ~/.tmux/plugins/tmux-command-macros/tmux-command-macros.tmux
chmod +x ~/.tmux/plugins/tmux-command-macros/tmux-command-runner.sh
# step 2
# manually add `run-shell ~/.tmux/plugins/tmux-command-macro/tmux-command-macro` in your tmux.
# step 3
tmux source ~/.tmux.conf
You can add your own custom macros to ~/.tmux/plugins/tmux-command-macros/custom-macros
.
Example on tmux config:
$ cat ~/.tmux.conf
# setup tmux-text-macros
set -g @tcm-window-mode vertical
run-shell ~/.tmux/plugins/tmux-command-macros/tmux-command-macros.tmux
- Not support to recording the macros.
- Not able interactive the tmux.
Tell where is macron location.
How to split the tmux window
horizontal
vertical
full
-> new window
Setting the keybind for tmux-text-macros to execute.
A Example Macros:
[
{"require":"mane"},
{"require-from-cmd":"cd /Tools; export MANE=$(fzf)"},
{"send-string":"hi, you are input some text: "},
{"send-from-cmd":"echo $mane"},
{"sleep":"1"},
{"send-key":"C-c"},
{"debug":"Hi, I am only show on your runner session"},
{"send-string":"hi, test b64 working: "},
{"send-from-cmd-b64":"ZWNobyAkbWFuZQo="},
{"sleep":"1"},
{"send-key":"C-c"},
{"send-string":"I am kill your firefox"},
{"run-command":"pkill firefox"},
{"sleep":"1"},
{"send-key":"C-c"},
{"sleep":"30"}
]
As you can see, each one line is an action, you can define the actions you want.
Whenever you execute a Macros, a tmux session is automatically created.
Just show in the runner-session message.
Require Variables from user input and save it to the environment variable.
For example: {"require":"mane"}
and {"send-from-cmd":"echo $mane"}
.
Pre-Run command.
It is very useful when in the user ui.
Pre-Run command for b64.
sleep for 5 seconds.
send a raw key, C-c
for Ctrl + c
, Enter
for Enter key
.
When specifying keys, most represent themselves (for example ‘A’ to ‘Z’). Ctrl keys may be prefixed with ‘C-’ or ‘^’, and Alt (meta) with ‘M-’. In addition, the following special key names are accepted: Up, Down, Left, Right, BSpace, BTab, DC (Delete), End, Enter, Escape, F1 to F20, Home, IC (Insert), NPage/PageDown/PgDn, PPage/PageUp/PgUp, Space, and Tab.
Reference: tmux's manual KEY BINDINGS
Just send a string.
Just send a string and base64 decode.
run command and sent it to tmux panel.
run command for base64 format and sent it to tmux panel.
run command, but DO NOT sent it to tmux panel.
run command for base64 format, but DO NOT sent it to tmux panel.
Press Prefix /
(normally Ctrl+b /
) and choose a string by choosing it with the arrow keys or by entering a search string and press enter.