Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrapping layouts of windows #612

Closed
alex35mil opened this issue Aug 12, 2016 · 10 comments
Closed

Bootstrapping layouts of windows #612

alex35mil opened this issue Aug 12, 2016 · 10 comments
Labels
help wanted Contributions wanted towards the issue ❔ Type: Question Issue is a question relating to Hyper (please use zeit.chat or https://spectrum.chat/hyper for this)

Comments

@alex35mil
Copy link

alex35mil commented Aug 12, 2016

One of the key parts of term tool for me is ability to quickly bootstrap project environment.

Eg:

  1. send object w/ params to the scaffolder script
  2. create N windows
  3. set cwd of each window
  4. run custom command in each window

Here is the demo what I do w/ iTerm and its Apple Script API: https://cl.ly/foOf

Looks like currently w/ HyperTerm API I can accomplish only #2 — create N windows. Eg via shortcut:

const { globalShortcut } = require('electron');

exports.onApp = (app) => {
  [1, 2, 3, 4].forEach(n => {
    globalShortcut.register(`Cmd+Control+Alt+${n}`, () => {
      for (let i = 0; i < n; i++) app.createWindow();
    });
  });
};

Here is API sketch.

// Via some channel sending signal
// w/ serializable params to Hyperterm API
exports.onSomeSignal = (app, params) => {
  const { termOne, ...otherTerms } = params;

  app.createWindow(win => {
    win.setCwd(termOne.cwd);
    win.sendCmd(termOne.cmd);
  });

  // etc...
};

Have no idea if it's doable, or maybe there're other plans for such automation tooling for the future releases. Thoughts / directions please :)

@timothyis timothyis added help wanted Contributions wanted towards the issue ❔ Type: Question Issue is a question relating to Hyper (please use zeit.chat or https://spectrum.chat/hyper for this) labels Aug 12, 2016
@ppot
Copy link
Contributor

ppot commented Aug 12, 2016

@alexfedoseev Nice background I have the same ;) I would see this as a plugin that interpret your JSON file and process to create the environment once the app is started. Could you edit your post since #2 point to a closed Issue and not suitable for this concern?

@alex35mil
Copy link
Author

@ppot Oops, done :)

once the app is started.

I don't think that it's a good idea, since most of devs have multiple projects to start. Here's the general usecase for me: I start my main project, after sometime I have to change something in my oss module -> I switch to next desktop -> scaffold module's project, etc. So it should be something on demand, rather than on app start, I guess.

@ppot
Copy link
Contributor

ppot commented Aug 13, 2016

@alexfedoseev So somme kind of hterm-cli that execute your script?
Something like hterm exec ~/yourprojectpath/env.json ?

@alex35mil
Copy link
Author

@ppot Here are my thoughts on this take. From this line:

hterm exec ~/yourprojectpath/env.json

I assume that hterm-cli is already a layout engine, which takes json config and bootstrap layouts. In the end it sounds fine (except I wouldn't put that in the core, but stand alone plugin), but as a first step I think Hyperterm should expose some low level API, around which such engine can be built. As an example I can point to the same old iTerm and itermocil. iTerm provides unopinionated low-level AppleScript API which gives ability to spawn the window, pass command to this window and so on. Around this API was built opinionated itermocil tool — w/ cli, its format of config etc. This decoupling of low level API and higher level abstractions is more flexible, and it will work for the cases when some devs will want to do something very special, which is not possible w/ higher level tool or even build their own engine (for example I don't use itermocil and use AppleScript API directly, b/c of some limitations/issues of this tool).

@ppot
Copy link
Contributor

ppot commented Aug 13, 2016

@alexfedoseev hterm-cli is just theoretical. But I understand the need to pass execution settings interpreted as action to the terminal. Having a low level API would definitely be great. It definitely need an update to let plugins pass command script directly to the term. This require some work but can be done yes.

ps: What is your shell theme?

@alex35mil
Copy link
Author

ps: What is your shell theme?

@ppot I don't remember where it came from, but here's hyperterm colors:

colors: {
  black: '#383d43',
  red: '#c66363',
  green: '#c0c86d',
  yellow: '#eac171',
  blue: '#80a2be',
  magenta: '#b193ba',
  cyan: '#90c9c1',
  white: '#c2c5c3',
  lightBlack: '#636363',
  lightRed: '#a04041',
  lightGreen: '#8b9440',
  lightYellow: '#ec9c62',
  lightBlue: '#5d7f9a',
  lightMagenta: '#82658c',
  lightCyan: '#5e8d87',
  lightWhite: '#6d757d'
}

@smebberson
Copy link

@alexfedoseev, @ppot I stumbled across hyperterm while looking for some kind of easy automation support for bootstraping development project environments. Is this sort of development still on the radar?

@alexfedoseev, are you able to share you iTerm script that you used to get that working?

@smebberson
Copy link

@alexfedoseev, have you come across https://www.npmjs.com/package/hyperlayout?

@alex35mil
Copy link
Author

@alexfedoseev, have you come across https://www.npmjs.com/package/hyperlayout?

@smebberson Yep, I've seen this one, but I miss tmuxinator API, it's the best scaffolding tool I used so far. I might just copy it some other day.

You can find my scaffolding scripts for iTerm here: https://github.com/alexfedoseev/dotfiles
But I'm afraid it won't be obvious how things work together as it's a crazy mix of iTerm, Alfred & kwm scripts.

@smebberson
Copy link

@alexfedoseev yeah, I agree, it would nice to have similar capabilities. I did discover your dotfiles and yeah, it was a crazy mix. I think I mostly understood, but I think I'll opt for something simple for now and go with hyper and hyperlayout. It's in between what I'm doing now and the full thing you can get iTerm/tmuxinator.

I'm really loving hyper so far!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Contributions wanted towards the issue ❔ Type: Question Issue is a question relating to Hyper (please use zeit.chat or https://spectrum.chat/hyper for this)
Projects
None yet
Development

No branches or pull requests

5 participants