News for hackers. Stuff that matters.
Re:Getting Started with Tmux by azemetre on Sunday December 11, 2022 @10:00AM (#33943735)
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.

Re:Getting Started with Tmux by quesera on Sunday December 11, 2022 @10:23AM (#33943913)
Also 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

Re:Getting Started with Tmux by yummypaint on Sunday December 11, 2022 @02:32PM (#33946618)
I have been wanting this for years! Thanks for sharing
Re:Getting Started with Tmux by dahart on Sunday December 11, 2022 @11:29AM (#33944581)
This 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.
Re:Getting Started with Tmux by AbundantSalmon on Sunday December 11, 2022 @10:12AM (#33943829)
This 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 :)
Re:Getting Started with Tmux by pletnes on Sunday December 11, 2022 @10:14AM (#33943842)
Did you check out tmuxinator? Sounds like you reinvented it, cool, but maybe there’s some inspiration to be had.
Re:Getting Started with Tmux by dahart on Sunday December 11, 2022 @11:17AM (#33944472)
> 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.

Re:Getting Started with Tmux by pletnes on Sunday December 11, 2022 @11:20AM (#33944502)
Absolutely. I think it depends on ruby, too, which is unusual. It’s anyway got some good ideas - declarative config files, etc.
Re:Getting Started with Tmux by eropple on Sunday December 11, 2022 @11:46AM (#33944768)
Not 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

Re:Getting Started with Tmux by azemetre on Sunday December 11, 2022 @10:34AM (#33944003)
I 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

Re:Getting Started with Tmux by ghoward on Sunday December 11, 2022 @10:10AM (#33943812)
I 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-a...

Re:Getting Started with Tmux by kzrdude on Sunday December 11, 2022 @10:09AM (#33943800)
And 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.
Re:Getting Started with Tmux by azemetre on Sunday December 11, 2022 @10:39AM (#33944048)
Yes! 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

[2] https://github.com/charmbracelet/vhs

Re:Getting Started with Tmux by vasili111 on Sunday December 11, 2022 @10:46AM (#33944107)
Could you please share your script?
Re:Getting Started with Tmux by azemetre on Tuesday December 13, 2022 @03:40PM (#33975415)
Can'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