OSX tmux configuration session open file in vim automatically

221 views Asked by At

So I have tmux and vim running in iterm2 on OSX. I have a tmux.conf file that sources a session in ~/.tmux/ called 'left'. I have successfully loaded this session with three panes. Two panes in a left column and a single pane on the right. I have also managed to successfullly target my upper left pane to run ls at startup.

I'm looking for a solution to open a particular file in vim on startup in one of the remaining panes.

The successful ls command is as follows:
send -t 0 lsa enter

Assuming the above syntax for the successful ls command, I have tried:
send -t 1 vim ~/Path/to/my/file enter

also:

send -t 1 cmd=vim ~/Path/to/my/file enter
with no luck

Tmux simply returns it with no spaces as a string:
vim/Users/path/to/file

It appears it the space is getting lost in the shuffle and no longer delimiting the command from the argument.

Thanks in advance to any help or suggestions.

1

There are 1 answers

1
AudioBubble On BEST ANSWER

Explicitly inserting a space should do it:

send -t 1 vim space ~/Path/to/my/file enter

or you can quote command arguments (I prefer this one):

send -t 1 'vim ~/Path/to/my/file' 'enter'