vercel / hyper

A terminal built on web technologies
https://hyper.is
MIT License
43.2k stars 3.5k forks source link

Use Hyper CLI to open multiple windows and tabs with configuration #462

Open zanedev opened 8 years ago

zanedev commented 8 years ago

It could be nice to launch HyperTerm with a few tabs and run a few scripts in each one automatically. Like a project configuration. Is that possible now?

timneutkens commented 8 years ago

It's not build into hyperterm at the moment. You could write a plugin for it though 👍 You mean kind of like iTerm2's profiles right?

zanedev commented 8 years ago

Maybe even simpler, rather than full fledged profiles at first. Like the ability to launch a command to a new tab in the current window. I imagine it would be reused as a command line launcher in general but maybe if it's called from hyperterm it launches a new tab, if it's called outside hyperterm it launches hyperterm with that command. The hyperterm app doesn't seem to accept command line arguments currently as far as I can tell...

Sure it would be fun! I've never worked with electron but would like to get into it. Any ideas to point in the right direction would help.

timneutkens commented 8 years ago

Hmm that would be a cool idea.. like a echo 'example' | hyperterm which opens a new tab and executes the command passed in. Same goes for hyperterm "echo 'example'" Maybe if you're a little crazy you could hook into that and add the hyperhyper command which does the same with this soundbit https://www.youtube.com/watch?v=F7aKqJsuPDg :joy: :joy: echo 'example' | hyperhyper

zanedev commented 8 years ago

I imagine it would need to be like textmate or webstorm where we'd bundle a separate command line tools binary/script that can be optionally installed in the path. Or maybe that's overkill it could be simpler to just pass params to the app living in Applications.

austin-guevara commented 7 years ago

Hey, guys – any update to this in Hyper? I was hoping for something even as simple as the ability to open Hyper.app from the command line. Not necessary pass a command into it.

Is that possible? I know you can just run: open "/Applications/Hyper.app"

But that launches a new instance every time. Instead, is there a way to have it launch and open a new instance if it's not already running (and only launch a new window if it is already running)?

thrkmmr commented 7 years ago

At work we use scripts to open new tabs in Konsole that SSH into the various servers we deploy and test on (about a 100 different servers). The background colors (actually the profiles) are different for different environment types. For example:

konsole --new-tab --profile Test -e ssh someserver.ourdomain.com

If this was possible in Hyper I would switch.

ilkka commented 7 years ago

I noticed that one can run /Application/Hyper.app/Contents/MacOS/Hyper /path/to/directory to open a new instance of the app, with the given path as the working directory, but that's as far as it goes. Also it shows up in alt-tab etc. as a separate app which is not very handy.

rmwaite commented 7 years ago

The trouble with passing a directory or command to the executable on the command line is that new windows created from that session seem to "inherit" those properties. So for example, if you open a window using /Application/Hyper.app/Contents/MacOS/Hyper /path/to/directory and then create a new window, it will also open in that directory. The Windows alt-tab and macOS dock will see this instance as a different application if Hyper was already running with no (or different) arguments. I'm unfamiliar with Electron or the Hyper code to see if this is something that can be fixed - such that different instances launched with different command line arguments are grouped together as the same application. I also think it is worth considering a separate command line utility with the ability to hook into the running app the create new windows and run commands, etc - but again, I'm not familiar enough with the technologies here to know if this is naive.

borela commented 7 years ago

Having a .hyperproj file to launch pre configured tabs would be extremely useful, any progress on this?

ppot commented 7 years ago

This is in my long task list to enable profile accessibility!

dsturm commented 7 years ago

There is a typo in @ilkka and @richardwaite comments: it is /Applications/Hyper.app/Contents/MacOS/Hyper /path/to/directory. That is quite handy if you want to open hyper over GitKraken.

albinekb commented 7 years ago

@borela that seems perfect for a plugin!

tkodev commented 7 years ago

Would enable many use cases: such as allowing sftp programs to launch hyper for SSH, a support for a myriad of "cd_to" like tools (that also work from any application), etc.

I'm a little surprised that hyper doesn't support any command line arguments - since it's application can be categorized as command line tool (to some extent) !

Alternatively I could just fork and make my own hyper version, but I would love official update support :(

chabou commented 7 years ago

Indeed you could just fork and make your own hyper version... ...and make a PR to have this in an official update 😄

Royedc4 commented 7 years ago

@richardwaite @dsturm @ilkka Thanks /Applications/Hyper.app/Contents/MacOS/Hyper /path/to/directory Works as expected.

jacquescrocker commented 6 years ago

New tab support would be great, along with kicking off a command to start. I have this scripted out (via applescript) in Terminal.app. But its ugly. I'd want to run a script called "dev/start" in my project that looks something like this:

#!/usr/bin/env bash

hyper --tab --title "Server" --script "cd $HOME/myProject/server && bundle exec rails s"
hyper --tab --title "Console" --script "cd $HOME/myProject/server && bundle exec rails c"
hyper --tab --title "Specs" --script "cd $HOME/myProject/server && bundle exec guard"
hyper --tab --title "Frontend" --script "cd $HOME/myProject/frontend && bundle exec middleman start"

That would open up 4 tabs automatically, name them, and then kick off a script for each

I'm totally open to alternative ways of doing it also. But the end result should be 4 named tabs with 4 different processes.

Thanks!

timothyis commented 6 years ago

Woops, I didn't totally understand the issue 🙈

I'll change the title to be more accurate to the new hyper CLI 👌

elijahgagne commented 6 years ago

I feel compelled to write in to describe my use case for this functionality. I currently have PowerShell functions that open new tabs in ConEmu and establish new ssh.exe, mysql, psql (Postgres), sqlcmd (SQL Server), sqlplus (Oracle), and other connections. In my PowerShell profile, I also have a function that reads in all the servers and databases from a CMDB at startup and creates aliases for them. That allows me to start typing the name of a system, tab complete it, press enter, and get a new tab with an SSH, database, or other connection, etc.

If the hyper cli gets a function that lets me create tabs from the command line and I can use arbitrary shells with hyper, then I think a lot of SysAdmin/DBA types would be interested in hyper.

volumetric commented 5 years ago

New tab support would be great, along with kicking off a command to start. I have this scripted out (via applescript) in Terminal.app. But its ugly. I'd want to run a script called "dev/start" in my project that looks something like this:

#!/usr/bin/env bash

hyper --tab --title "Server" --script "cd $HOME/myProject/server && bundle exec rails s"
hyper --tab --title "Console" --script "cd $HOME/myProject/server && bundle exec rails c"
hyper --tab --title "Specs" --script "cd $HOME/myProject/server && bundle exec guard"
hyper --tab --title "Frontend" --script "cd $HOME/myProject/frontend && bundle exec middleman start"

That would open up 4 tabs automatically, name them, and then kick off a script for each

I'm totally open to alternative ways of doing it also. But the end result should be 4 named tabs with 4 different processes.

Thanks!

This is totally what I am looking for. Guake Terminal has something very similar to this and I have a terminal starter script that i run after system start. This is very helpful and preps your terminal session for your work.

dewetblomerus commented 5 years ago

Working on micro-services I sometimes have 4 different servers to start before testing my code. Just telling them all to start in different tabs would be amazing!

zerdos commented 5 years ago

@dewetblomerus, take a look on this: https://github.com/zerdos/modern-web-app-skeleton/blob/master/.hyperlayout

pcnate commented 5 years ago

New tab support would be great, along with kicking off a command to start. I have this scripted out (via applescript) in Terminal.app. But its ugly. I'd want to run a script called "dev/start" in my project that looks something like this:

#!/usr/bin/env bash

hyper --tab --title "Server" --script "cd $HOME/myProject/server && bundle exec rails s"
hyper --tab --title "Console" --script "cd $HOME/myProject/server && bundle exec rails c"
hyper --tab --title "Specs" --script "cd $HOME/myProject/server && bundle exec guard"
hyper --tab --title "Frontend" --script "cd $HOME/myProject/frontend && bundle exec middleman start"

That would open up 4 tabs automatically, name them, and then kick off a script for each

I'm totally open to alternative ways of doing it also. But the end result should be 4 named tabs with 4 different processes.

Thanks!

I would expect that with electron being slow to startup, there would be a need for some launcher app to track these and wait until the GUI app fully executes

lou-bi commented 5 years ago

I would like to try writing this plugin. Does the api provide the necessary to hook such option on start, or is a fork required ?

Circuit8 commented 5 years ago

I'd definitely love to see this feature come to life :+1:, I really love Hyper and this would bring it to perfection for me

taylorjdawson commented 5 years ago

Curious about the answer to @BonLouis's comment, as well as, justification/reasoning on why this should be a plugin instead of a built in feature? Are enough of the hyper internals exposed for this to be a plugin? Thanks!

chabou commented 5 years ago

I think that Hyperlayout plugin does exactly what you want :)

taylorjdawson commented 5 years ago

Hmm interesting seems to do what everyone is asking for? What's missing from the Hyperlayout plugin that doesn't resolve this issue?

pcnate commented 5 years ago

Interesting. I'll have to try that out later on

elijahgagne commented 5 years ago

Some things I'd like that might not be included in the Hyperlayout plugin are: 1) Ability to create a layout that uses different shells (e.g. PowerShell, Bash, cmd.exe) 2) Ability to create a layout by passing parameters (without creating/editing a file)

To elaborate on (2), for example, I'd create a Bash or PowerShell function that takes a parameter for the server name. When the function is called, it creates a new tab, runs ssh, and passes in all the relevant paraments to connect to a server. It seems that hyperlayout could do this, but would require creating files. I wouldn't want to do this, especially because the files might contain credentials.

I only skimmed Hyperlayout so I could have easily missed that it covers 1 and/or 2.

chabou commented 5 years ago

1 I think this feature can be added to Hyperlayout 2 We need to add ability to Hyper to pass CLI args to plugins.

I really don't think it should be a core feature but Hyper should definitely make this feature possible with plugins.

pcnate commented 5 years ago

hyperlayout is currently not maintained and doesn't work for me on Win 10. There is a hyperlayout2 on npm but it didn't seem to work either.

Luiggi370z commented 5 years ago

Hi, I had the same issue in windows 10, so after some research within the code, it looks like there is an issue with the reading of the hyperlayout file and at the end the data contains some ansi codes.

So I made some modifications, in the file index.js at line 160, I applied a stringify to the data and then clean all the ansi codes and json strings, then parse into an obj pass it in line 163.

After that it works fine :)

taylorjdawson commented 5 years ago

@Luiggi370z maybe you should submit a PR!

pcnate commented 5 years ago

@taylorjdawson https://github.com/timolins/hyperlayout/#this-repo-is-currently-unmaintained

There are open PRs and an old commit history image

taylorjdawson commented 5 years ago

@pcnate commit to the hyperlayout2 one maybe?

pcnate commented 5 years ago

Tried that one. It seems to require the original be installed

kanavpruthi commented 3 years ago

Is this issue still open? I am a first time contributor here.

yuis-ice commented 3 years ago

Still opening?

samuelneff commented 2 years ago

@pcnate Fork a hyperlayout3 :)

2-X commented 2 years ago

I would also really like this feature and the ability to auto-populate a command without executing it

I have a bunch of data scrapers that I run at work and want to open 6 windows so I can run them all and debug them each individually and re-run them. Also would be good for demos

chabou commented 2 years ago

hyper-broadcast can help (even if this it not exactly what you want)

LabhanshAgrawal commented 2 years ago

I'm planning to basically rewrite the cli and add support for arguments and such to be passed to hyper. But it will take some time as I'm caught up with work etc. Thanks for everyone's patience.

chabou commented 2 years ago

Great news @LabhanshAgrawal! Thank you for your hard work 🙏

rubenhak commented 2 years ago

I'd love to see a way to reopen a layout. This would be super helpful when working with microservices.

Solaris17 commented 9 months ago

Curious if this ever made it? I was looking for a way to auto open a tab and run a command just this morning. For context, at work we ssh to bastion hosts. It would be nice to have this automatically kick off in another tab when I open hyper.

Vortigern-The-Grey commented 1 month ago

This still in the works?