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

implemented support for mutliple shell definitions #1347

Closed
wants to merge 1 commit into from

Conversation

AlmirKadric
Copy link

@AlmirKadric AlmirKadric commented Jan 6, 2017

I've implemented an additional menu item in File which allows you to select other shells that may have been configured inside your config file. My use case was for Windows (Bash vs Powershell), but this would apply to macos and linux for anyone who uses more than a single shell flavour. I wanted to make this a plugin, however the work was too integrated for this to be possible (or rather so simple enough).

Possible enhancements to this PR:

  • don't show menu item if shells is not defined in config
  • add possibility of accelerator shortcut definition from config file

Please let me know if any of the above or other fixes are required, and I'll jump on it as soon as I can.

P.S. PR checks are failing due to external code which I didn't touch. Seems someone pushed bad code to master...

.gitignore Outdated
@@ -11,3 +11,5 @@ npm-debug.log
.hyper.js
.hyper_plugins

# IDEs
.idea
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this to your global .gitignore

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

@AlmirKadric AlmirKadric Jan 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah good point, thanks for that
will do 👍

.gitignore Outdated
@@ -10,4 +10,3 @@ npm-debug.log
# optional dev config file and plugins directory
.hyper.js
.hyper_plugins

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you put that blank line back again? 😅

Copy link
Author

@AlmirKadric AlmirKadric Jan 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, sorry for not noticing that XD

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually it was the other way around, the new line was missing in the repo
my IDE inserted it according to the .editorconfig

@@ -50,6 +49,7 @@ const config = require('./config');

config.init();

const createMenu = require('./menu');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move it up there where it was before? There's no need for this change 🙌

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually there is a need for this change, the createMenu file now relies on configuration options, therefore must be required after the config is initialised.

@@ -1,11 +1,15 @@
'use strict';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need use strict 😅

Copy link
Author

@AlmirKadric AlmirKadric Jan 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To use ES6 features on node properly it is required
e.g. my use of for (const shellName of Object.keys(shells)) { will break without it. Other than node 6 the above behaviour change with or without use strict. Without it shellName is set on the first iteration and remains constant for all other iterations. With it shellName is a constant to the scope of the loops inner block, however changes properly with each iteration.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If anyone else is confused try this in node 5

var a = [1,2,3,4,5,6]; for (const b of a) { console.log(b); }

vs

'use strict'; var a = [1,2,3,4,5,6]; for (const b of a) { console.log(b); }

Removing the 'use strict'; would essentially mean dropping support for anything less than node 6.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it's OK now since hyper is running on node 7.4 since #1848 👌

@@ -12,14 +12,16 @@ import getRootGroups from '../selectors';
import {setActiveSession, ptyExitSession, userExitSession} from './sessions';

function requestSplit(direction) {
return () => (dispatch, getState) => {
return (options) => (dispatch, getState) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the parenthesis around options – it's not needed for a single function argument

lib/index.js Outdated
@@ -64,16 +64,16 @@ rpc.on('session clear req', () => {
store_.dispatch(sessionActions.clearActiveSession());
});

rpc.on('termgroup add req', () => {
store_.dispatch(termGroupActions.requestTermGroup());
rpc.on('termgroup add req', (options) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the parenthesis around options – it's not needed for a single function argument

rpc.on('termgroup add req', () => {
store_.dispatch(termGroupActions.requestTermGroup());
rpc.on('termgroup add req', (options) => {
store_.dispatch(termGroupActions.requestTermGroup(options));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean??? that's a function call

lib/index.js Outdated
});

rpc.on('split request horizontal', () => {
store_.dispatch(termGroupActions.requestHorizontalSplit());
rpc.on('split request horizontal', (options) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

rpc.on('split request horizontal', () => {
store_.dispatch(termGroupActions.requestHorizontalSplit());
rpc.on('split request horizontal', (options) => {
store_.dispatch(termGroupActions.requestHorizontalSplit(options));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean??? that's a function call

lib/index.js Outdated
});

rpc.on('split request vertical', () => {
store_.dispatch(termGroupActions.requestVerticalSplit());
rpc.on('split request vertical', (options) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

rpc.on('split request vertical', () => {
store_.dispatch(termGroupActions.requestVerticalSplit());
rpc.on('split request vertical', (options) => {
store_.dispatch(termGroupActions.requestVerticalSplit(options));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean??? that's a function call

Copy link
Member

@matheuss matheuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlmirKadric Thanks for the PR and sorry for the delay!

Please fix the minor issues I outlined in the review 👌

@matheuss
Copy link
Member

matheuss commented Jan 28, 2017

Besides that:

  • Could you please explain what I should have in my .hyper.js? I tried a couple of combinations for shells, but couldn't get it to work – the new session was always opened with my default shell
  • You would need to add checks to the ui reducer for the possible values of shell – we wouldn't want people to set a empty '' path for the shell, for example. Check here for an example of how to do it
  • don't show menu item if shells is not defined in config definitely! 😄

@AlmirKadric
Copy link
Author

My .hyper.js shells configuration looks like this:

    // the shell to run when spawning a new session (i.e. /usr/local/bin/fish)
    // if left empty, your system's login shell will be used by default
    shell: 'C:\\cygwin64\\bin\\bash.exe',

    // for setting shell arguments (i.e. for using interactive shellArgs: ['-i'])
    // by default ['--login'] will be used
    shellArgs: ['--login'],

    // for environment variables
    env: {},

    // Additional shells
    shells: {
        bash: {
            path: 'C:\\cygwin64\\bin\\bash.exe',
            args: ['--login'],
            env: {}
        },
        powershell: {
            path: 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe',
            args: [],
            env: {}
        }
    },

@AlmirKadric
Copy link
Author

@matheuss I'll fix the other suggestions as well. Caught up with something else right now, will jump on it as soon as I'm done with that.

@AlmirKadric
Copy link
Author

AlmirKadric commented Jan 28, 2017

@matheuss after taking another look at the code, a reducer isn't required.
Currently if an empty shell path is provided it will be falsey causing it to fall back to the default shell (behaviour of default shell options as it falls back to system default if falsey).
If an invalid shell path is provided...well we can't really check that (unless we check if that file really exists?)
Also for the other options, empty entries are fine, if invalid options well it will break, though not sure how i can validate environment variables and shell startup arguments.

Any other suggestions or corrections to my above statements welcome.

@AlmirKadric
Copy link
Author

BUMP @matheuss @albinekb
any movement on this?
are there any actionable items left on my side?

app/index.js Outdated
@@ -186,7 +186,8 @@ app.on('ready', () => installDevExtensions(isDev).then(() => {
// If no callback is passed to createWindow,
// a new session will be created by default.
if (!fn) {
fn = win => win.rpc.emit('termgroup add req');
const shellOpts = options.shellOpts;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to test if options.shellOpts exist

@AlmirKadric
Copy link
Author

bump????

lib/index.js Outdated
});

rpc.on('split request horizontal', () => {
store_.dispatch(termGroupActions.requestHorizontalSplit());
rpc.on('split request horizontal',options => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lack of space rpc.on('split request horizontal', options => { ✌️

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@albinekb
Copy link
Contributor

Sorry @AlmirKadric have not had time to look at this, will look trough it tonight 🤘

@Stanzilla
Copy link
Contributor

@albinekb did you have time yet? Really would love to get this in.

app/menu.js Outdated
submenu: []
};

for (const shellName of Object.keys(shells)) {
Copy link
Contributor

@albinekb albinekb May 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would save Object.keys(shells) as a const since you're using it twice in this file? 🤔

const shellKeys = Object.keys(shells)

?

@AlmirKadric AlmirKadric force-pushed the feature/moreShells branch from bac6c0c to 638f461 Compare May 21, 2017 13:27
@AlmirKadric
Copy link
Author

Pulled from master and squashed into a single commit

Copy link
Contributor

@albinekb albinekb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌 for me this is ready for merge

@albinekb albinekb added 👀 Awaiting Response Issue or PR is awaiting a response from the author and removed Status: Rebase Needed labels May 21, 2017
@albinekb
Copy link
Contributor

ping @matheuss

@Hypercubed
Copy link

I just gave this a try... works well. Needs a rebase and some error trapping (for example bad paths).

@MartyGentillon
Copy link
Contributor

One other minor change: this needs to be documented (probably in the default config file), otherwise people won't find the new feature.

@tulsileathers
Copy link

Is this going to be merged in anytime soon?

@jack-guy
Copy link

jack-guy commented Aug 5, 2017

Anything specifically holding this PR up? I want this badly enough that I'd take it on if @AlmirKadric doesn't have the time to move forward with it.

@AlmirKadric
Copy link
Author

AlmirKadric commented Aug 8, 2017

@Harangue from what I'm reading above, the remaining items are

  • error trapping for bad paths (though I would prefer he commented on that on the actual lines)
  • documentation in the default config file
  • merge develop and rebase

@albinekb @matheuss can you please confirm this is the last of the changes
I'm happy to make them, but in all fairness this PR has been sitting here for a terribly long time (6+ months)

I've actually made my own terminal multiplexer using similar technologies as a result since I couldn't wait for my changes to be merged, and branching from hyper didn't make sense as I wanted to make some fundamental design changes (would have been a complete rewrite of the underlying architecture)

@cameron-pascal
Copy link

cameron-pascal commented Dec 4, 2017

@albinekb, @matheuss Has this PR stalled / what it's current status? This would be an amazing feature to have on windows.

@eamodio
Copy link

eamodio commented Feb 6, 2018

I would really love to see this in as well -- what is still left to be done, since this was started about a year ago?

@AlmirKadric
Copy link
Author

AlmirKadric commented Feb 6, 2018

@CameronMaxwell @eamodio
I'm still waiting on feedback from the core team as to finalizing what is needed to get this PR merged. I don't fancy fixing things if only to have more comments made for fixes. Once they confirm what's required, I'll updated the PR for merging.

Alternatively feel free to take a look at my own terminal multiplexer here:
https://github.com/AlmirKadric-Published/exTerm-electron
Its not as advanced/clean/pretty in some regards, but is ahead in others, when compared to hyperterm. If it suits your needs but you need this or some other minor features, I'm happy to make the changes for you. Its been more than enough for my current needs, albeit one really annoying bug that I haven't had the time to fix completely. I'm more than happy to be more active on it if there is a community of users.

@jordandrako
Copy link

Did this die with version 2's release?

@Stanzilla
Copy link
Contributor

Stanzilla commented Oct 15, 2019

@AlmirKadric willing to pick this up again? I think a solution like Terminus https://github.com/Eugeny/terminus would be nice

@AlmirKadric
Copy link
Author

@Stanzilla unfortunately too much time has passed and I have since moved await from hyper and build my own terminal multiplexer using similar tech. The current beta version fills all my needs including the above feature. Even if I were to pick this up again, I believe enough code has changed that I would be essentially re-implementing the feature. As such I would suggest anyone who needs the feature to start again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👀 Awaiting Response Issue or PR is awaiting a response from the author WIP
Projects
None yet
Development

Successfully merging this pull request may close these issues.