Skip to content

Instantly share code, notes, and snippets.

@dbhagen
Forked from legowerewolf/hyperstart.bat
Last active September 18, 2019 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbhagen/9f92627e39442d9f20cb52845fccc62a to your computer and use it in GitHub Desktop.
Save dbhagen/9f92627e39442d9f20cb52845fccc62a to your computer and use it in GitHub Desktop.
@ECHO off
:top
CLS
ECHO Choose a shell:
ECHO [1] cmd
ECHO [2] zsh
ECHO [3] PowerShell
ECHO [4] bash
ECHO [5] Python
ECHO.
ECHO [6] restart elevated
ECHO [7] exit
ECHO.
CHOICE /N /C:1234567 /M "> "
CLS
IF ERRORLEVEL ==7 GOTO end
IF ERRORLEVEL ==6 powershell -Command "Start-Process hyper -Verb RunAs"
IF ERRORLEVEL ==5 python
IF ERRORLEVEL ==4 bash
IF ERRORLEVEL ==3 powershell
IF ERRORLEVEL ==2 wsl zsh
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
$knownshells = @(
@{
Name = "CMD"
Executable = "C:\Windows\System32\cmd.exe"
},
@{
Name = "Powershell 5.1"
Executable = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
},
@{
Name = "Powershell 6 (Core)"
Executable = "C:\Program Files\PowerShell\6\pwsh.exe"
},
@{
Name = "Bash on Ubuntu"
Executable = "C:\Windows\System32\wsl.exe"
ArgumentList = @("-d", "Ubuntu")
}
@{
Name = "Git Bash"
Executable = "C:\Program Files\Git\git-bash.exe"
}
) | Where-Object { Test-Path -Path $_.Executable }
"Choose a shell:"
$index = 1; $teststring = ""
foreach ($shell in $knownshells) {
"[$index] $($shell.Name)"
$teststring += $index++
}
""
do { $keyPress = [System.Console]::ReadKey() } until ($teststring.Contains($keyPress.Key));
$choice = $knownshells[($keyPress.KeyChar.ToString() -as [int]) - 1]
Start-Process -Path $choice.Executable -NoNewWindow -Wait -ArgumentList $choice.ArgumentList
exit

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment