Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I didn't see this posted in this thread, but by far the most useful thing I've seen with tmux is the "send-keys" command - https://blog.damonkelley.me/2016/09/07/tmux-send-keys/

This is nice in isolation, but it becomes powerful if you have a persistent target and have a keybinding to issue a send-keys command to the persistent target.

For instance, in my vimrc, I have a set of commands bound like so:

noremap <leader>R :silent !tmux send-keys -t 2.2 startjob Enter <CR>

noremap <leader>E :silent !tmux send-keys -t 2.2 killjob Enter <CR>

where startjob is a local alias to starting my development environment and 2.2 is the target.

This means from any of the vim instances I have, I can start and stop my development environment without having to do so in a running vim instance, and get all the appropriate logging in a terminal that I can switch to when I choose.

This becomes even more powerful with a build script I have triggered by an inotifywait that's running in 2.1 that will build my entire environment with all its dependencies (yes, I need to do it this way because building one project may require another to be rebuilt, and just triggering 'make' in vim doesn't cut it) whenever a file is written.

It reduces a lot of the pain with developing a C++ project in the terminal and lets me get back to the work of just thinking about what needs to be done.

'Send-keys' is, to me, the killer feature of tmux.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: