Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to add custom commands to tmux?

Tags:

tmux

I have some commands in mind that I don't want to create keybinds for and would prefer to use command mode for them. For example, I want something like:

<C-a>:restart-guard

That I can have run a script to run some commands in my guard window

Is this possible?

like image 567
Josh Bodah Avatar asked Dec 25 '22 22:12

Josh Bodah


1 Answers

You can't define user defined commands directly But you can always call a tmux script with so (shortest alias of source-file) or a program with ru (shortest alias of run-shell)

For so, you need to give the path to the command or to have the tmux server to start in the folder where your custom commands are

Here is a simple example, you put your restart-guard script in ~/.tmux/commands you start tmux using a scipt :

#!/bin/bash
cd ~/.tmux/commands
tmux

then inside tmux, do

<C-a>:so restart-guard

I am currently looking for a way to have the directory where you started tmux and not the ~/.tmux/commands directory when starting

like image 67
y.petremann Avatar answered Dec 28 '22 14:12

y.petremann