2

I have added in my PowerShell profile functions to set locations as following:

function myPath {set-location "D:\SomePath\"}

Now when I call it in Windows Terminal with PowerShell the command myPath it redirects to the specific one. With the command start . I can open this directory in Windows Explorer. Is there any way that I can introduce custom keyboard shortcuts that will open Window Explorer to the current directory like Ctrl+E to replace somehow start . command?

jAdex
  • 472
  • 1
  • 5
  • 15
  • 1
    So you're looking for a way to open the current Powershell working directory in Explorer with a keyboard shortcut, is that correct? – PMental Nov 15 '20 at 17:49
  • @PMental yes, that is exactly what I am looking for. – jAdex Nov 15 '20 at 18:13

1 Answers1

3

Try the following, using the built-in PSReadLine module's Set-PSReadLineKeyHandler cmdlet:

Set-PSReadLineKeyHandler -Chord 'ctrl+e' { Invoke-Item $PWD.ProviderPath }

Pressing Ctrl+E should then bring up the host platform's file browser, showing the current directory.


Note that an alternative to defining a keyboard shortcut is to submit the following command, which uses the built-in ii alias for the Invoke-Item cmdlet:

ii .
mklement0
  • 382,024
  • 64
  • 607
  • 775