Hacker News new | comments | show | ask | jobs | submit login
Show HN: Cockpit – create tmux panes and windows with ease (27ae60.com)
125 points by jaisonjustus 45 days ago | hide | past | web | favorite | 47 comments



It's quite an indictment of the current state of our tooling (not just tmux) that such an application as this is necessary. Why isn't it easy to configure this in tmux itself, and persist the resulting configuration?


My use case for building Cockpit was to easily generate scripts for my different layouts. These scripts I use with https://github.com/fitztrev/shuttle so I could load my workspace with a single click. I am not sure if this application is necessary. However, I think everyone can find their own use cases.


I wonder if there is some sort of inverse relationship between having comprehensive features, thereby being self-contained (think Smalltalk), versus having a continuous dialog with the imperfect outside environment (think perl). I'm sure this is implicit in the famous "Worse is Better" essay, if not explicit.

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!)


This doesn't let you persist ad hoc setups, but I have a `~/lib/tmux-code` file that I source from `~/.bash_profile` with entries like this:

    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 highly recommend https://github.com/tmuxinator/tmuxinator if you haven't tried it, I've actually used it to run whole microservice environments locally and works without a hitch


It's already simple to split panes in tmux, but the ability to persist them sounds like a good Hacktoberfest project.


this has already been solved by several plugins. this one works well:

https://github.com/tmux-plugins/tmux-resurrect


The defaults are a little funky but they’re easy enough to change. I have mine so prefix+s splits horizontally and prefix+v splits vertically. And then prefix+(H,J,K,L) resizes.


This looks really nice!

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.


+1 The mnemonics that come with tmux are short and intuitive enough such that everything ive needed is just a ctrl+b away. Curious what the use case is for this


Example where I would have needed this a while ago:

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)


Thanks. I'm also constantly resizing and re-adjusting my work space for which I have binded keys in my .tmux.conf. Cockpit helps me get started :)


what are the pros and cons to using tmux as opposed to say multiple instances of a terminal emulator split up using ratpoison?


The one major advantage is preserving sessions and re-attaching to them later, e.g. when you're ssh'ed into a remote machine or VM and you don't want to lose your setup.

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.


I happen to be a vim user. tmux, vim, vim-tmux-navigator, and some comfortable configurations in .vimrc and .tmux.conf can be a force multiplier for one's workflow. If you like vim, then it makes a lot of sense. If you don't, there's still probably some merit, but, maybe less of an incentive.

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.


pro: use anywhere, including while ssh'd, and share sessions with others. con: not that easy to use -- kind of like vim or emacs.

I personally use tmux because it's "one window" and it is supported on every environment I can think of.


Big con for me: scrolling sucks. Even o latest 2.x, which is indeed better, but still light years away from native.


When you say scrolling, do you mean with something other than a keyboard?

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?


Nowadays, it's basically a simple way to let process running after existing the shell and reattaching later, for me.

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.


Neat. I personally use https://github.com/tmuxinator/tmuxinator for this.


I really like https://github.com/oxidane/tmuxomatic No easier way to configure tmux layouts. Sadly it is not actively developed.


Thanks. For me, I wanted scripts, didn't want to install the gem as my layouts were relatively simple and similar. Yes, tmuxinator is quite a tool :)


Thanks :)


Nice tool. I suggest showing the script beside the window so it can easily be cut-and-pasted. Browser downloading is a hassle especially with tmux on a remote server.


Thanks. Your point to show the script is duly noted. It is actually a great idea. Let me incorporate the suggestion in upcoming updates.


I was using tmuxinator for this, but found that all of my sessions were essentially the same thing except for the name and the working directory.

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...


Nice work. I’ve been using teamocil (https://github.com/remiprev/teamocil) so far (which is doubly nice because its configs can be used with plain iterm via itermocil) but will take a look at this too!


Please try to use a different name this clashes quite with http://cockpit-project.org/

But otherwise it’s a nice tool


Thank you. I have a small attachment to the name ‘Cockpit’. Three years ago, me and my friends, we used to spend quite some time in hacking projects or automating our workflow. It was at that time, we created a a tool called ‘Cockpit’ (https://github.com/27AE60/cockpit) for configuring Terminal workspace in Linux. Over the years, I started concentrating on one terminal. And when I shifted to iTerm2 along with Tmux, I wanted to spend less time in configuring workspace and more on my code. Then, I realized, I end up with similar Tmux layouts for most of my prototypes and I wanted to reduce my time in re-loading the projects. I wanted a visual representation of Tmux and flexibility in terms of scripts instead of installing applications. This tool reminded me of my old project and so, I couldn’t think a better name than Cockpit.


How do you create 3 equal sized horizontal windows with Cockpit?


It is not possible to create 3 equal sized horizontal panes with Cockpit. What I normally do is, create three horizontal splits in Cockpit and in tmux, I use `leader-key space` which makes tmux cycle through available layouts, and in one of them is equal sized horizontal windows.


Great job, this is something that I'd definitely use - especially when I can't be bothered with installing extra gems.


I use tmuxomatic, which is very simple to use with it's visual layout. Works really well.

https://github.com/oxidane/tmuxomatic


Nice application!

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.


Thanks. Good find! I will fix it.


This is awesome. Side note, you may want to rename your project to avoid a clash with kubernetes' cockpit UI for kubernetes cluster monitoring.


Thanks. I've received a similar comment in this thread regarding 'Cockpit' name conflict. I have explained my reasons in reply to the comment by @recentdarkness


There is a bug when you close windows (the round yellow thing remains). Also can you name the windows?


Here is an image which details all the icons in Tmux. http://cockpit.27ae60.com/img/demo-configure-ii.png

Also updated in http://cockpit.27ae60.com/help.html


Actually, clicking on the round yellow circle is the way to rename the windows. I will improve the experience in upcoming releases.


The layout seems to be broken on Firefox for Android. The pane with the demo fully covers the text


Thanks for the feedback. I have not thought about this tool being used in mobiles as my primary focus was for desktop users.


I thought about building something like this every time I messed with tmuxinator layouts. Nice!


Thanks.I wanted an easy script creator from my dynamic yet simple layouts, so I thought of building Cockpit. Now, all I do is re-run the script generated from the app.


What I want is iTerm2 hotkeys for tmux so I don't have to remember both.



After reading that, the Tmux integration for iterm2 (tmux -CC) seems to work a lot better. Thanks!




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: