jimeh / tmuxifier

Tmuxify your Tmux. Powerful session, window & pane management for Tmux.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Passing command line arguments

RobbHendershot opened this issue · comments

Is there any way to pass command line arguments through from invocation into a particular pane in the script? I would like to specify a server to ssh to using something like tmuxifier load-window debug servername and as part of the window creation pass the "servername" to ssh in a pane. Here is a test script I wrote -

new_window "debug"
split_h 30
split_v 50
run_cmd "htop"  2   # runs in active pane
run_cmd "sudo tail -f /var/log/messages" 3
run_cmd "echo vars :: $# :: $0 :: $1 :: $2 :: $3" 1
select_pane 1

Using the command above to invoke it I would expect "servername" to show up somewhere in the echo statement but I get nothing except the name of the window-

vars :: 1 :: /sysadmin/home/rdhender/.tmuxifier/libexec/tmuxifier-load-window :: debug :: ::  

I LOVE tmuxifier by the way, thank you for creating it!

There's nothing like that at the moment, but you might be able to use environment variables. I've never tried this myself, though, so don't hold me to it :)

Basically invoke tmuxifier like so:

SERVERNAME=foobar tmuxifier load-window debug

And then do something like this in the window layout file:

run_cmd "echo $SERVERNAME"

If it works correctly, your new session will start with echoing foobar. Please let me know if it works or doesn't work :)

Off the top of my head I think it might at least work if the tmuxifier call actually starts a new tmux server, but if it's just connecting to an existing server I'm not sure if the env is forwarded.

I'll have a think about passing additional arguments to layout files. Off the top of my head I think it can get rather confusing and impractical when session layouts that themselves are loading window layouts are thrown into the mix though. We'll see :)