Comments (12)
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.
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.
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.
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.
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.
Oh yes :)
from teamocil.
Aaaaaand there is another issue. Apparently the layout strings are not compatible across tmux versions. Too bad.
from teamocil.
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.
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.
@scientist1642 Yeah, I think it was in the README.md
before the 1.0 rewrite. I’ll add it back 😄
from teamocil.
@scientist1642 Done! 7f8a47f
from teamocil.
@remiprev cool! 🎉
from teamocil.
Related Issues (20)
- Teamocil is wiping out GEM_HOME and GEM_PATH HOT 7
- Teamocil throwing error "show-window-options: illegal option -- v"
- Environment variable for `root` does not work HOT 1
- Quoting in yaml
- Example using session HOT 1
- wish: support for XDG_HOME_STANDARD-- put config files under ~/.config
- Feature Request: Recreating panes on changes in the command
- Ability to set environment variables
- Resizing pane? HOT 3
- Feature request: setup commands
- Feature request: generate config from tmux session
- Load ./.teamocil file if no file is provided HOT 3
- Directory per pane HOT 1
- Teamocil does not respect base-index HOT 3
- Domain name dead HOT 1
- Teamocil does not work with Ruby 2.7.0
- Ability to read variables from a variable file in teamocil.
- Custom config path? HOT 2
- Create tmux session instead of editing existing one HOT 1
- Session being renamed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from teamocil.