Show HN: Cockpit – create tmux panes and windows with ease
cockpit.27ae60.com
cockpit.27ae60.com
function ins-code {
env_name=code
long_name=insurance
short_name=ins
tmux_session=${short_name}-${env_name}
if tmux list-sessions | grep ${tmux_session}; then
tmux attach-session -t ${tmux_session}
else
cd ~/src/${long_name}/backend/app/models && \
tmux new-session -d -s ${tmux_session} && \
tmux rename-window -t ${tmux_session}:1 models
cd ~/src/${long_name}/backend/app/controllers && \
tmux new-window -t ${tmux_session}:2 -n controllers
cd ~/src/${long_name}/backend/app/views && \
tmux new-window -t ${tmux_session}:3 -n views
cd ~/src/${long_name}/backend/app/assets/stylesheets && \
tmux new-window -t ${tmux_session}:4 -n css
tmux select-window -t ${tmux_session}:1 && \
tmux -2 attach-session -t ${tmux_session}
fi
}
Then I can just say `ins-code` and it will either launch a new session or attach if it already exists.I mean: the author of tmux could have bundled the package with a comprehensive environment. But what really is there, beyond Unix and the browser? If it exists, people haven't heard if it, and even if they had, would just as soon reinvent it. At any rate, the inevitable imperfections and inpedance-mismatch with users' existing workflow / UI would surely invite brutal criticism. (For example, when Plan 9 came up here a few years back, a big chunk of the discussion was about how ugly the GUI seemed to them!)
It's not for me, though. Maybe I'm not a very good systems engineer, but I've got a decent .tmux.conf. Between writing automation and trying to make sense of the mess I've inherited, I'm constantly splitting, resizing, and re-adjusting my work space to suit the task at hand.
After almost every reboot on my laptop I start a tmux with a certain layout with some semi-long-running processes which I want active and not daemonized, I can also not start them at the same time. I start them in a tmux with the layout split into 4 quadrants, then create a single new window so I don't see them all the time and can work there.
Took me at least 2h to figure that out, how to split it programmatically and start everything in the correct "corner". Now it's just running a script and not having to anything manually.
This would have probably saved me 2h. And I have totally forgotten everything again now, so much for "just a ctrl-b" away. (Using tmux daily, but not in THIS way)
I personally use tmux because it's "one window" and it is supported on every environment I can think of.
I thought this is something I wanted, but when I finally got around to getting mouse inputs working the way I thought they should, I realized that mousing around a terminal is kind of weird. Granted, I still use my mouse for copy/pasta operations, but I hope to eventually break that habit in time.
What's your workflow with tmux like?
But I had much greater ambitions in the past which I've given up mostly due to scrolling, clearing scrollback inserting a bunch of whitespace instead of actually clearing, etc.
I scroll with the mouse a lot, it's more tolerable with the keyboard, but it's still not as good as native interaction.
It also messes with the colors sometimes. For some reason, screen doesn't.
I've never used ratpoison, but just read into it. Sounds pretty great, actually. If the key bindings are simple enough, I suppose it could be pretty similar. But, as a sibling comment pointed out, it works most everywhere. Where I go, my configuration comes with me.
Ratpoison could possibly be better (I keep meaning to give it a shot), although one thing I really enjoy about using tmux is being able to quickly open, shuffle, reorganize, and close panes with only the overhead of starting a new shell.
So I just wrote a shell script that takes a directory, using basename for the session name, starting up what ever windows and panes it needs to. I have two variants, one for generic dev stuff (shell and an editor) and the other is for rails work (shell, editor, logs, rails db and a rails c in the last window).
https://github.com/vhodges/dotfiles/blob/master/utils/bin/tm... or https://github.com/vhodges/dotfiles/blob/master/utils/bin/tm...
But otherwise it’s a nice tool
I found a small bug: When you have an edit field open and try to open another one (command/session name/window name), the second one will just be cleared to blank.
Also updated in http://cockpit.27ae60.com/help.html