4 ms·
I would like to do the following: - Start work day, type a command to create a tmux session which would create x windows, dropping me specifically in directorie
by deanclatworthy 6y ago
I would like to do the following:
- Start work day, type a command to create a tmux session which would create x windows, dropping me specifically in directories that I specify in some config file
- I would like to have scripts that are run for four scenarios a) on creation of the tmux session, re-attach to the tmux session, detatch from tmux session, destroy tmux session.
Or is there a better tool for this?
Use-case is basically I want to stop all work-related resources at end of work day including docker containers, but restart them the following day. Ideally it would be as simple as tmux a -t work to get started again which would start necessary docker containers from a bunch of directories, and then tmux detach would kill the containers
- enriquto 6y ago> Or is there a better tool for this? You can write very simple scripts that perform the actions that you describe. It does not seem that there's a better tool than the shell, for this.
- jakeva 6y agoYou might find tmuxinator (https://github.com/tmuxinator/tmuxinator https://github.com/tmuxinator/tmuxinator) helpful. It doesn't do everything you describe, but I use it to spin up sessions configured per project.
- Jtsummers 6y agotmuxinator https://github.com/tmuxinator/tmuxinator https://github.com/tmuxinator/tmuxinator There are other solutions but I used this one for a while and liked it. Then stopped doing as much development at home (work is Windows) and haven't used it in a while. It's easy(ish) to create different configs for different needs. I basically had a Common Lisp IDE or a C++ IDE or whatever set of things I commonly used.
- ascagnel_ 6y agoLook into tmux-resurrect[0]. It allows you to save and restore tmux sessions, and an accept-list of running processes within those sessions. Ideally, you'd get the tmux session into the state you want re: windows, CWDs, running processes, etc., save it, and then restore from that session in the future. [0] https://github.com/tmux-plugins/tmux-resurrect https://github.com/tmux-plugins/tmux-resurrect
- joseluis 6y agothis plugin has been a godsend for me, since I like to have many sessions open, and I can resume my setup exactly how I left it in each and everyone of them, at any time.
- lolive 6y agoCan we have tmux inside tmux, and still benefit from the session resume [and the sessions-in-session resume, of course]?
- asdff 6y agoThere are tons of examples on how to do this in the shell. Here is some inspiration: https://stackoverflow.com/questions/54954177/how-to-write-a-tmux-script-so-that-it-automatically-split-windows-and-opens-a-se https://stackoverflow.com/questions/54954177/how-to-write-a-...
- krysp 6y agoVery similar to tmuxinator, but in python: https://github.com/tmux-python/tmuxp https://github.com/tmux-python/tmuxp I use this one as I found it easier to set up, and a bit more intuitive to script. Also if you use python rather than ruby, it's easier to understand!