Git Product home page Git Product logo

windows-terminal-context-menu's Introduction

🧾 Windows-terminal-context-menu

Inspired from Windows terminal issue Add "open Windows terminal here" into right-click context menu #1060. Thanks to you all giants ❀

Windows terminal is an excellent terminal. But it does not offer a basic function which is right click context menu!
Without it, I have to cd to my working directory everytime. It's inefficient.

So I wrote this script to deal with it.

Feature

  • Two layers of context menu
  • Auto parse settings.json to contruct menu
  • With uninstaller

Todo

  • Custom icon for profile

Install

  1. Clone this repo git clone https://github.com/kerol2r20/Windows-terminal-context-menu

  2. Run powershell (no need to get admin access right)

  3. Change the execution policy Set-ExecutionPolicy Unrestricted -scope CurrentUser

  4. Run SetupContextMenu.ps1 script

⚠️ If you find no item in your context menu, it may be caused by the old style profiles.json. You can delete %LocalAppData%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\profiles.json and restart Windows terminal. The new one will be generated. Ref to microsoft/terminal#4556

Uninstall

  1. Run SetupContextMenu.ps1 -uninstall:$true

Config

This script will parse the settings.json file to generate menu items. However you can customize it.
Put any icon file into icon folder and modify the config.json like the following.

{
    "global": {
        "extended": false
    },
    "profiles": {
        "{a5a97cb8-8961-5535-816d-772efe0c6a3f}": {
            "icon": "arch.ico",
            "label": "Arch Linux"
        },
        "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}": {
            "showRunAs": true
        },
        "{b453ae62-4e3d-5e58-b989-0a998ec441b8}": {
            "hidden": true
        }
    }
}

Config reference

  • global
    • extended[bool]: if set this to true, context menu will only show up when right click with shift
  • profiles
    • guid[string]: this GUID of your profile defined in settings.json
      • hidden[bool]: overwrites the visibility of the profile, if defined
      • icon[string]: filename of your ico file, you must put this file in icon folder
      • label[string]: context menu label
      • showRunAs[bool]: add run as administrator item for this profile

Misc

I'm not sure that icons file are legal or not. If you feel it is not ok, please tell me. Thanks.

windows-terminal-context-menu's People

Contributors

akr2002 avatar clinmanc avatar felipecrs avatar jan-di avatar kerol2r20 avatar kiritodv avatar koushikphy avatar nmutsu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

windows-terminal-context-menu's Issues

Add keyboard shortcut

Add & to some strings can be useful:
$contextMenuLabel = "Open Windows &Terminal here"

In function Add-SubmenuReg (add parameter $index)
`[void](New-ItemProperty -Path $regPath -Name "MUIVerb" -PropertyType String -Value "&$($index): $($label)")

Run-As window flashes during execution

As is probably already known, the powershell run as command for admin flashes windows during execution, and because of that it kinda looks janky.

This led me to look for a solution. I found that nearly all script solutions were just unreliable and/or too cumbersome. So I fixed it in a simpler way, using an executable designed to hide all windows + run as admin. Much easier.

I would issue a pull request, however I'm not sure whether this addition will be welcome.

Please check out my latest 2 commits in the repo to see what I did if you like it. I'd love to submit it as a PR if it's acceptable.
https://github.com/cherryleafroad/Windows-terminal-context-menu

P.S. I'm sure you're probably thinking, "but what's in the exe?". No worries, I got you covered!
Check my other repo to see the code
https://github.com/cherryleafroad/run-hidden
https://github.com/cherryleafroad/run-hidden/blob/master/Program.cs

In fact, there is a benefit towards my solution. It is MUCH FASTER at startup than the previous solution, and more stable and reliable (from a aesthetic pov)

Does not work if username has a space in between

The contextmenus does not work if the username has a space in between. I was having the problem. Then I fixed it by putting the path inside an inverted comma. I believe you can replace line 140 i.e this

$command_f = "$env:LOCALAPPDATA\Microsoft\WindowsApps\wt.exe -p `"$profileName`" -d `"%V\.`""

to this

$command_f = "`"$env:LOCALAPPDATA\Microsoft\WindowsApps\wt.exe`" -p `"$profileName`" -d `"%V\.`""

Could not find path

When I execute the scripte with powershell "AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json"
he tells me that this file doesn't exist.

Adding Git Bash does not work

I added git bash in my windows terminal:

{
    "guid": "{00000000-0000-0000-0000-000000000001}",
    "name": "Git Bash",
    "commandline": "\"%PROGRAMFILES%/git/usr/bin/bash.exe\" -i -l",
    "icon": "C:/Program Files/Git/mingw64/share/git/git-for-windows.ico",
    "backgroundImage": "%OneDrive%/.config/.assets/git.jpg",
    "backgroundImageOpacity": 0.1,
    "startingDirectory": "%OneDrive%"
},

My config file looks like:

"{00000000-0000-0000-0000-000000000001}": {
    "icon": "git.ico",
    "label": "Git Bash"
},

However, after running SetupContextMenu.ps1 I assigns all Shells successfully except Git Bash. Any clue what’s the issue here?

Error with Google Drive

Latest version of Windows Terminal from Chocolatey
Windows 1909

When launching any of the profiles (cmd, ubuntu or powershell) within the google drive or any of its subfolders an error occurs: error 0x8007002

It can been:
image

Add Context Menu to Drives

Hello,
Please Add Context Menu to Drives (like below image)
Windows Explorer

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Drive\shell\WindowsTerminal]
"ExtendedSubCommandsKey"="Directory\\ContextMenus\\WindowsTerminal"
"Icon"="C:\\Users\\Alireza\\AppData\\Local\\WindowsTerminalContextIcons\\terminal.ico"
"MUIVerb"="Open Windows Terminal here"

Directory Paths not working for Cygwin

Cygwin maps Linux POSIX paths to Windows Path and prefixes the current path with /cygdrive/

That means, assume you are in this folder: C:\Users\Username\git\project the corresponding cygwin path would be /cygdrive/c/Users/Username/git/project

Could you prepend the /cygdrive/ if a users defines an id which contains cygwin in the commandline property. I’m not a Powershell scripter, so it woud take too much time for me.

Error while installing firebase packages into flutter project

###hey guys, whenever I add firebase( core, auth, database ) to my flutter project I face this error:

FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring project ':firebase_core'.
Could not resolve all artifacts for configuration ':firebase_core:classpath'. Could not download builder.jar (com.android.tools.build:builder:3.3.0) > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/3.3.0/builder-3.3.0.jar'. > Premature end of Content-Length delimited message body (expected: 30631026; received: 6553552 Could not download kotlin-stdlib-jdk8.jar (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.11) > Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.11/kotlin-stdlib-jdk8-1.3.11.jar'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.11/kotlin-stdlib-jdk8-1.3.11.jar'. > jcenter.bintray.com Could not find jetifier-processor.jar (com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta02). Searched in the following locations: https://dl.google.com/dl/android/maven2/com/android/tools/build/jetifier/jetifier-processor/1.0.0-beta02/jetifier-processor-1.0.0-beta02.jar Could not find bundletool.jar (com.android.tools.build:bundletool:0.6.0). Searched in the following locations: https://dl.google.com/dl/android/maven2/com/android/tools/build/bundletool/0.6.0/bundletool-0.6.0.jar Could not find jetifier-core.jar (com.android.tools.build.jetifier:jetifier-core:1.0.0-beta02). Searched in the following locations: https://dl.google.com/dl/android/maven2/com/android/tools/build/jetifier/jetifier-core/1.0.0-beta02/jetifier-core-1.0.0-beta02.jar Could not download kotlin-reflect.jar (org.jetbrains.kotlin:kotlin-reflect:1.3.11) > Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.3.11/kotlin-reflect-1.3.11.jar'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.3.11/kotlin-reflect-1.3.11.jar'. > jcenter.bintray.com Could not download kotlin-stdlib-jdk7.jar (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.11) > Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.3.11/kotlin-stdlib-jdk7-1.3.11.jar'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.3.11/kotlin-stdlib-jdk7-1.3.11.jar'. > jcenter.bintray.com Could not download kotlin-stdlib.jar (org.jetbrains.kotlin:kotlin-stdlib:1.3.11) > Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.3.11/kotlin-stdlib-1.3.11.jar'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.3.11/kotlin-stdlib-1.3.11.jar'. > jcenter.bintray.com Could not download kotlin-stdlib-common.jar (org.jetbrains.kotlin:kotlin-stdlib-common:1.3.11) > Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-common/1.3.11/kotlin-stdlib-common-1.3.11.jar'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-common/1.3.11/kotlin-stdlib-common-1.3.11.jar'. > jcenter.bintray.com Failed to notify project evaluation listener. Could not get unknown property 'android' for project ':firebase_core' of type org.gradle.api.Project. Could not find method implementation() for arguments [project ':firebase_core_web'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 8m 1s Exception: Gradle task assembleDebug failed with exit code 1

I have followed the instruction of installing firebase sdk into a flutter project and this is my app\build.gradel:

  ` def localProperties = new Properties()
  def localPropertiesFile = rootProject.file('local.properties')
  if (localPropertiesFile.exists()) {
   localPropertiesFile.withReader('UTF-8') { reader ->
    localProperties.load(reader)
   }
  }

  def flutterRoot = localProperties.getProperty('flutter.sdk')
  if (flutterRoot == null) {
 throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the 
  local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
 flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

lintOptions {
    disable 'InvalidPackage'
}

defaultConfig {
    // TODO: Specify your own unique Application ID 
  (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.saad2002.falafeelo"
    minSdkVersion 16
    targetSdkVersion 28
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

buildTypes {
    release {
        // TODO: Add your own signing config for the release build.
        // Signing with the debug keys for now, so `flutter run --release` works.
        signingConfig signingConfigs.debug
    }
   }
 }

flutter {
source '../..'
 }

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics:17.4.3'
 }

`

Check for parent reg key

So fun fact, I didn't have a 'shell' key in either Directory or Directory\Background in HKCU, so the script kept failing until I realized why, and manually created them. You may want to add some logic to check for both of those keys prior to attempting to create the "WindowsTerminal" key under them.

Admin Terminal Option

It'd be great if by right-clicking with SHIFT the menu would instead show options to open each terminal in elevated Administrator mode (prompting user for admin privileges if needed)

No submenu

Hi! It would be great if there is an option to have all the shortcuts directly in the context menu and not in a submenu. With this upgrade, it would be faster to open the terminal only by 1 click, instead of doing two clicks and losing time.

Thank you for making this tool <3!

Option to show the menu on Shift-RightClick

I have a few suggestions :

  1. Add an option to make the items appear straight on main context menu instead of submenu.
  2. Add an option to make the menu items to appear on Shift-RightClick instead of RightClick only
  3. I know there is a separate issue, but - either make the items work when you select a drive or do not show them when you select a drive if possible. The current situation is not very pleasant as we get a non working menu item on drive letter.
  4. I hope you're closely following the git issue and we'll get a non PowerShell dependent (annoying blue popup) "run as administrator" as soon as there is a working solution for that.

Keep up the good work !

Allow users to set extended

Thank you for this project!
I like my default shell menu to be clean. Most dev options I "hide" using the Extended string value in regedit.

I’ve got no clue about PowerShell logic, but maybe you can allow users to set parameters. That is for this scenario: SetupContextMenu.ps1 --Extended

Script fails when "WindowsTerminalContextIcons" folder doesn't exist

Hey, thanks for the script. You should add the following:

mkdir $resourcePath

before copying the icons so that the script doesn't fail to run the first time if the folder doesn't exist. And maybe an rmdir for uninstall.

Even after doing so, something seems off with the registry keys, I'm getting this:
image

Any clue why that might happen? Edit: seems like it's not picking up my profiles correctly from the raw JSON although it's valid.

Thanks!

Doesn't Read Profile List for Old Config Format

User configs generated before microsoft/terminal#4556 store their profile list under .profiles rather than .profiles.list. There should probably be a disclaimer in the readme if not a check in the program to handle this on the fly.

@kalaschnik this is what caused the error you got, you can get around it by either deleting and regenerating your user config or editing the script to source .profiles instead of .profiles.list

Set-ExecutionPolicy RemoteSigned Not working

Hi,
First of all I would like to thank you very much for the script, it is working very well,
very happy about that πŸ˜„.

But there is a small issue in the readme

In the readme you say that for make the script working you need to set executionPolicy to remoteSigned, but with the policy like that the script will not be launched by powershell.
For make it run you must to set the policy to Unrestricted with the command
Set-ExecutionPolicy Unrestricted


And then the script will be launched correctly

Icons in windows terminal dont show up unless launched as admin

Launching windows terminal using the context menu after running this script bugs out the icons on the profiles on windows terminal. This doesn't seem to happen when using the "as administrator" option, or when running windows terminal through its icon.

Opening windows terminal from context path:
image

Opening windows terminal form context path as admin:
image

Opening windows terminal from regular shortcut:
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.