Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@ECHO off
:top
CLS
ECHO Choose a shell:
ECHO [1] cmd
ECHO [2] bash
ECHO [3] PowerShell
ECHO [4] Python
ECHO.
ECHO [5] restart elevated
ECHO [6] exit
ECHO.
CHOICE /N /C:123456 /M "> "
CLS
IF ERRORLEVEL ==6 GOTO end
IF ERRORLEVEL ==5 powershell -Command "Start-Process hyper -Verb RunAs"
IF ERRORLEVEL ==4 python
IF ERRORLEVEL ==3 powershell
IF ERRORLEVEL ==2 bash
IF ERRORLEVEL ==1 cmd
CLS
ECHO Switch or exit?
ECHO [1] Switch
ECHO [2] Exit
CHOICE /N /C:12 /D 2 /T 5 /M "> "
IF ERRORLEVEL ==2 GOTO end
IF ERRORLEVEL ==1 GOTO top
:end

Hyperstart

Short script for Windows that allows you to select which shell you want when Hyper starts. As flexible as the windows command line.

Install

  1. Grab the script from below.
  2. Save it wherever you want.
  3. Set your shell to '' (meaning CMD on Windows) and your shellArgs to ["/C", "path\\to\\your\\hyperstart.bat"]
  4. Additional steps
  • To enable the "launch elevated" line, Hyper needs to be on the PATH.

Customize

Add a shell

  1. Add another ECHO line with a new number: ECHO [4] Python
  2. Add the corresponding number to the CHOICE line: CHOICE /N /C:1234
  3. Add the corresponding IF ERRORLEVEL line below the CLS line: IF ERRORLEVEL ==4 python
  4. Fix up the other numbers, if necessary.
@chabou

This comment has been minimized.

Copy link

chabou commented Apr 6, 2018

Awesome work!

@chabou

This comment has been minimized.

Copy link

chabou commented Apr 6, 2018

It would be awesome to embed this, in a hyper plugin

@genio

This comment has been minimized.

Copy link

genio commented May 9, 2018

This doesn't seem to work in hyper v2.0


[Window Title]
Error

[Main Instruction]
A JavaScript error occurred in the main process

[Content]
Uncaught Exception:
TypeError: Cannot read property 'resize' of undefined
    at Server.Window.rpc.on (C:\Users\genio\AppData\Local\hyper\app-2.0.0\resources\app.asar\ui\window.js:146:14)
    at emitOne (events.js:115:13)
    at Server.emit (events.js:210:7)
    at Server.ipcListener (C:\Users\genio\AppData\Local\hyper\app-2.0.0\resources\app.asar\rpc.js:33:11)
    at emitTwo (events.js:125:13)
    at EventEmitter.emit (events.js:213:7)
    at WebContents.<anonymous> (C:\Users\genio\AppData\Local\hyper\app-2.0.0\resources\electron.asar\browser\api\web-contents.js:266:13)
    at emitTwo (events.js:125:13)
    at WebContents.emit (events.js:213:7)

[OK]
@szul

This comment has been minimized.

Copy link

szul commented May 14, 2018

Getting the same error now as @genio.

@wordyallen

This comment has been minimized.

Copy link

wordyallen commented May 22, 2018

same error

@mckernanin

This comment has been minimized.

Copy link

mckernanin commented Jun 15, 2018

I had the same issue, the first part confused me. /C represents a flag passed to cmd.exe, not your C drive. I put hyperstart.bat in my user folder, and the following setting works great for me:

    shell: '',
    shellArgs: ["/C","C:\\Users\\Kevin McKernan\\hyperstart.bat"],
@ammein

This comment has been minimized.

Copy link

ammein commented Jul 11, 2018

Bash Error

I got this error when opening bash :

'bash' is not recognized as an internal or external command,
operable program or batch file.
Microsoft Windows [Version 10.0.17134.165]
(c) 2018 Microsoft Corporation. All rights reserved

Solution Found :

Make sure you add your bash to PATH :

  1. Press Windows Key (Windows 10) and start typing edit environment variables
  2. Then you go to User Variable section and find text named path.
  3. Click on it and press edit.
  4. If you don't have this path C:\Program Files\Git\bin . Click New and Browse to that path.
  5. Save and Exit. You're done !
@JosiahSlade

This comment has been minimized.

Copy link

JosiahSlade commented Jul 12, 2018

@legowerewolf can you clarify how you PATH looks like for elevated line to work. I have hyper in my user var PATH but not sure if Im missing something since I'm getting the resize errors as well

@JosiahSlade

This comment has been minimized.

Copy link

JosiahSlade commented Jul 13, 2018

If you're having the resize error mentioned above, make sure the file hyperstart.bat is a windows batch file and not a text document. You may have it as a text if you saved it directly from the page. It worked for me once it's a batch file.

@brunomedeiros0121

This comment has been minimized.

Copy link

brunomedeiros0121 commented Mar 20, 2019

Nice job!

@sntnupl

This comment has been minimized.

Copy link

sntnupl commented Apr 5, 2019

Awesome Job!
I had the same issue as seen by @ammein above.
I did not want to add the ms-git's version of bash in my PATH, as I would soon setup WSL, and I want that application's bash to be in PATH.

So, if like me, you have multiple bashes :-), you can do the following:

@ECHO off
:top
CLS
ECHO Choose a shell:
ECHO [1] cmd
ECHO [2] bash
ECHO [3] PowerShell
ECHO [4] Python
ECHO.
ECHO [5] restart elevated
ECHO [6] exit
ECHO.

CHOICE /N /C:123456 /M "> "
CLS
IF ERRORLEVEL ==6 GOTO end
IF ERRORLEVEL ==5 powershell -Command "Start-Process hyper -Verb RunAs"
IF ERRORLEVEL ==4 python
IF ERRORLEVEL ==3 powershell
IF ERRORLEVEL ==2 "C:\Program Files\Git\bin\bash.exe"
IF ERRORLEVEL ==1 cmd

CLS
ECHO Switch or exit?
ECHO [1] Switch
ECHO [2] Exit

CHOICE /N /C:12 /D 2 /T 5 /M "> "
IF ERRORLEVEL ==2 GOTO end
IF ERRORLEVEL ==1 GOTO top

:end

In other words, you can give full path to the bash.exe you want to execute.
Once I install WSL, I will extend this script, to include 2 bash options, each pointing to their respective exes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.