4 ms·
I use TMUX to split screens so I can edit nginx-conf and restart the server form the the same view. That's probably the most basic usage for TMUX, but somebod
by neals 10y ago
I use TMUX to split screens so I can edit nginx-conf and restart the server form the the same view.
That's probably the most basic usage for TMUX, but somebody please enlighten me, what are some 'advanced' uses? How much more than splitting screens is there? Honest question.
- emilburzo 10y agoSlightly relevant: if you find yourself in vim and don't have tmux/are too lazy to open another SSH connection, you can use ":sh" to drop to a shell. So for the nginx edit conf/restart server scenario you would: # vim /etc/nginx/nginx.conf <make changes> :sh # drop to a shell # nginx -t # check config, let's assume it failed due to a missing "}" # exit # go back to vim <make changes> :sh # nginx -t && nginx -s reload # config check passed # exit # back to vim :q # exit vim #
- rz2k 10y agoCtrl-z will send Vim to the background (though you probably can't be in insert mode). `fg` in the shell will then bring the Vim session back to the foreground. If `:sh` doesn't give you your command history and the same working directory, that might be convenient.
- epberry 10y agoHere's a few ways I've used tmux: 1. Hierarchical context management. I use different sessions for different projects. One session might have my main development work, one session for a random debugging session for a coworker, one session for a side project or project euler challenge. Within each session I usually have multiple windows. For main development I have one window that has source code and development, one window for testing, and one window for command line/ data wrangling. Within each window I might have a couple panes, for example in testing I have a split screen with testing code on the left and the command line for running tests on the right. 2. Multiple paste buffers. Recently I had 3 or 4 environmental variables I was setting on some different devices. I stuck them into different copy paste buffers and went to town instead of repeatedly copying and pasting from a document. 3. Alerts. I'll often have a few jobs that run for between an hour and a couple hours that I want to just start and forget about. When they're done you can have tmux give you a notification on the window that the job was in and you can go check it out and do more work. Minor, but interesting use cases: - share tmux sessions with coworkers. I haven't done this as much but it's great for remote debugging. - process persistence. Use this all the time. No more nohup & business. - naming windows. I name almost all my windows like "test" or "hardware". - moving windows and panes around. You can move panes to different windows and windows to different sessions really easily. - save tmux state before shutdown. There's a separate plugin that does this but you an actually write your current session to disk and load it up again when you restart. EDIT: formatting
- spike021 10y agoIn one college class I was taking, we needed to continuously run a webservice from our computers for group projects. In all, we winded up pretty much having a NoSQL database, the backend itself (Nodejs/etc.), as well as other tools. So basically I set up a tmux session with panels for all those things. It was a good way to keep it all running without needing to always have it "open" per se. Also it's handy for running certain services/programs in the background when I ssh into a server.