3 ms·
I've only used tmux for about <year now but I immensely enjoy it. One of my favorite scripts to run is a tmux script that creates a new session with about 7 wi
by azemetre 4y ago
I've only used tmux for about <year now but I immensely enjoy it.
One of my favorite scripts to run is a tmux script that creates a new session with about 7 windows of running my company's project (one window for notes, 3 windows for the backend (runner, code, tests), and 3 windows for the client (runner, code, tests). It's even tweaked further to open up the code in vim, and when used in conjunction with something like harpoon.nvim I have access to my most used files with a few keystrokes. I now create similar scripts for all projects I work on for lengthy periods.
One script builds and runs the environment in the way I prefer to work. Tailored to my taste, for me.
Probably the best advice that I always took to heart was a co worker telling me to "just learn the command line." He really took the phrase "learn your tools" seriously. Now, after some decent experience, I finally feel like I have a decent box of specialty tools when heading to any job site.
- kzrdude 4y agoAnd just like learn your tools, also “make your tools”. This is what we do all the time. This is why we compare ourselves with craftspeople. We have in common that working on the craft includes improving and making your own tools to get the best result.
- azemetre 4y agoYes! I'm slowly moving towards these steps, it's my excuse for learning go and rust. There are some CLTs that don't exist for my need and I'm working towards creating them. I don't know if you've heard of charmbracelet [1] but they are a company that makes a lot of cool go libraries to assist creating CLTs and TUIs. One of which was on HN recently, VHS [2]. [1] https://github.com/charmbracelet https://github.com/charmbracelet [2] https://github.com/charmbracelet/vhs https://github.com/charmbracelet/vhs
- ghoward 4y agoI do this too! [1] It's amazing how well tmux works as a project setup tool. [1]: https://gavinhoward.com/2020/12/my-development-environment-and-how-i-got-there/ https://gavinhoward.com/2020/12/my-development-environment-a...
- AbundantSalmon 4y agoThis sounds like my setup! I literally have 1 button startup for starting all my normal programs (including split tmux windows, each running appropriate startup commands for what ever process they need) and it moves all my windows into their regular positions. I usually get into to work, plug in the laptop, press my button and go make coffee :)
- pletnes 4y agoDid you check out tmuxinator? Sounds like you reinvented it, cool, but maybe there’s some inspiration to be had.
- azemetre 4y agoI have not! I'll have to investigate more, because my little shell script is pretty basic (like 20 lines total, most of which was done for readability). https://github.com/tmuxinator/tmuxinator https://github.com/tmuxinator/tmuxinator
- dahart 4y ago> Sounds like you reinvented it Tmux comes with the ability to script it, intentionally and by design, and it’s very straightforward and simple to open several windows that launch commands in them. Tmuxinator doesn’t reinvent that, and it does add another dependency, and another layer of options and flags and project syntax to learn. The suggestion to check it out is great, but saying that people who don’t use it are reinventing it is a tad heavy handed. There are good reasons and legitimate scenarios to keep it simple with tmux scripting alone.
- pletnes 4y agoAbsolutely. I think it depends on ruby, too, which is unusual. It’s anyway got some good ideas - declarative config files, etc.
- eropple 4y agoNot the OP, but I did riff off of tmuxinator recently. tmuxed talks to tmux directly out-of-band to avoid running over user input and supports things like "wait before sending more input" for cases where `sleep` isn't desirable. I envisioned it being an orchestrator layer over tmux rather than a "new thing" to learn; while it's largely finished for my normal use cases I've been thinking about how sometimes it'd be awfully useful to be able to orchestrate tmux commands and not just send-keys. Single binary, too, so no Ruby dependency. I really should get it into Homebrew one of these days... https://github.com/eropple/tmuxed https://github.com/eropple/tmuxed
- quesera 4y agoAlso check out tmux-resurrect to save and restore tmux window/pane config including working directories and scrollback. It can also restore running programs, which is sometimes a reasonable thing to do. https://github.com/tmux-plugins/tmux-resurrect https://github.com/tmux-plugins/tmux-resurrect
- yummypaint 4y agoI have been wanting this for years! Thanks for sharing
- vasili111 4y agoCould you please share your script?
- azemetre 4y agoCan't post the specifics but something like this as a bash script, if you have any Qs LMK: #!/usr/bin/env bash tmux new-session -d -s sessionname tmux rename-window todo tmux send-keys -t todo "vim todo" Enter tmux new-window -d -n dot tmux send-keys -t dot "cd " Enter tmux new-window -d -n windowname tmux send-keys -t windowname "cd ~/reponame" Enter tmux send-keys -t windowname "commands to run" Enter tmux attach-session -d -t sessionname
- dahart 4y agoThis is exactly how I was introduced to tmux and learned to love it. Joined a web dev company who’s workflow was to start a swath of back-end servers each in a tmux pane. There were more than a dozen, so the tmux launch script made it simple and manageable. It’s nice to have the outputs in separate terminals, and to be able to restart them because the command’s in bash history, among many other little niceties.