Giter Club home page Giter Club logo

Comments (12)

remi avatar remi commented on May 25, 2024 2

I’ve been thinking about this for quite some times now, this is a feature I would also like to see.

The way I see it, a teamocil file is made from two main things: layout and commands.

Layout

I just added support for a layout option that you can user in window settings. Whatever you put in the layout option will be used in a tmux select-layout command, so you can use all of its supported values, like tiled, even-horizontal, main-vertical, etc. You can also use a custom tmux serialized layout, like bf75,203x51,0,0[204x25,0,0{76x25,0,0,58,127x25,77,0,59},204x25,0,26,60] which you can obtain by running this command in a window:

tmux list-windows -F "#{window_active} #{window_layout}" | grep "^1" | cut -d " " -f 2
Commands

As far as I’m aware, I don’t think it’s possible to extract the currently running command in each split. But I think the hardest part of building a teamocil layout is the actual splits layout.

So what I suggest is you manually build your layout, run the command above to extract its layout serialized string. You’ll then have something like this:

windows:
  - name: my new layout
    layout: "23f9,204x51,0,0{102x51,0,0,81,101x51,103,0[101x25,103,0,82,101x25,103,26{50x25,103,26,83,50x25,154,26,84}]}"

After that, you just have to create your splits array:

windows:
  - name: my new layout
    layout: "23f9,204x51,0,0{102x51,0,0,81,101x51,103,0[101x25,103,0,82,101x25,103,26{50x25,103,26,83,50x25,154,26,84}]}"
    splits:
      - cmd:
        - echo first
      - cmd:
        - echo second'
      - cmd:
        - echo third'
      - cmd:
        - echo fourth'

Hope that helps!

from teamocil.

gardiner avatar gardiner commented on May 25, 2024

Wow, cool! I've got to try this. Thanks for the suggestion!

Now that I'm thinking about it, it should be relatively easy to get the current working directory (for the "root" option). And maybe one can inspect the shell history for the latest command? Unfortunately I don't know much ruby, otherwise I'd try to create some kind of teamocil command for that task. I'll probably try a shell script first.

from teamocil.

gardiner avatar gardiner commented on May 25, 2024

Well, history does not work.
This on the other hand looks awful but seems to work: https://gist.github.com/3907932 ... It inspects the process list to find the last child process of each pane and then extracts the respective command. I guess someone who knows what he's doing should take a look at this instead ;)

from teamocil.

gardiner avatar gardiner commented on May 25, 2024

There are some issues with this approach. For starters, the order of panes in the layout string is apparently not the same as the order of panes as returned by the list-panes command. That's why the commands end up in the wrong pane. Not dramatic, but not nice. No idea so far how to fix this.

from teamocil.

remi avatar remi commented on May 25, 2024

For starters, the order of panes in the layout string is apparently not the same as the order of panes as returned by the list-panes command. That's why the commands end up in the wrong pane. Not dramatic, but not nice.

Yeah, I actually thought this would be an issue, but I figured it would be much simpler to move the commands around in the YAML file than trying to parse tmux layout string :)

from teamocil.

gardiner avatar gardiner commented on May 25, 2024

Oh yes :)

from teamocil.

gardiner avatar gardiner commented on May 25, 2024

Aaaaaand there is another issue. Apparently the layout strings are not compatible across tmux versions. Too bad.

from teamocil.

remi avatar remi commented on May 25, 2024

I’m going to close this issue now since I’ve added the layout key for windows. Extracting commands seems a bit unnecessary 😄

from teamocil.

scientist1642 avatar scientist1642 commented on May 25, 2024

Hi @remiprev,
Your comment about getting current layout from terminal is super helpful!
What do you think mentioning this trick in the README? as I think MANY people would like to have custom layout (saying that we can use tmux splitting and :resize-pane commands as we like and then save the custom layout)

from teamocil.

remi avatar remi commented on May 25, 2024

@scientist1642 Yeah, I think it was in the README.md before the 1.0 rewrite. I’ll add it back 😄

from teamocil.

remi avatar remi commented on May 25, 2024

@scientist1642 Done! 7f8a47f

from teamocil.

scientist1642 avatar scientist1642 commented on May 25, 2024

@remiprev cool! 🎉

from teamocil.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.