Scott Hanselman

Quake Mode Console for Visual Studio - Open a Command Prompt with a hotkey

January 21, '15 Comments [45] Posted in Tools | VS2012 | VS2013 | VS2015
Sponsored By

Back in March of 2013 when Phil Haack was deep into GitHub for Windows development we were going back and forth in email about how to quickly get into a shell from a specific project. I hate always having to paste in a "CD somedirectory" so I usually use some kind of "Command Prompt Here" right click menu.

TIP: A lot of people don't realize that you can Shift-Right-Click on a folder in Windows Explorer and you'll automatically get a "Command Prompt Here" menu item!

Anyway, Phil and I were emailing and he said (remember that GitHub for Windows (GHfW) was in development)...and I've always loved how the Quake console pops up when you press ~ in Quake.

I feel ashamed I didn't know this, but I just discovered that CTRL+ALT+D brings up the shell when in GHfW. We are considering ways to make our keyboard shortcuts more discoverable. Kind of like the `?` support we have on GitHub.com. We should totally make that a ~ shouldn't we? Like in Quake, Doom, etc.

And they did. When you're in GitHub for Windows just press ~ and you'll automatically get a new command prompt (or Bash Shell or PowerShell) and be dropped in to the current folder's directory. It's my most favorite feature about GitHub for Windows.

I mentioned this to Mads Kristensen yesterday and said we should build this feature into Visual Studio. Rather than waiting, he just created a little single purpose extension called Open Command Line. It works in Visual Studio 2012, 2013, and 2015.

Open Command Line

But it's the hotkeys that make it awesome. Now I'm not sure how I lived without it. Alt-Space and it opens up a prompt right where I need it. Go download the Open Command Line free Visual Studio extension now, and remember, it works in Visual Studio Community which is also free! You can set it to open CMD, PowerShell, or a custom prompt.

Oh, by the way, the overlay there that shows what hotkey I'm using, that's Carnac.

Related Links


Sponsor: Big thanks to the folks at Infragistics for sponsoring the feed this week! Responsive web design on any browser, any platform and any device with Infragistics jQuery/HTML5 Controls.  Get super-charged performance with the world’s fastest HTML5 Grid - Download for free now!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb
Wednesday, 21 January 2015 08:52:25 UTC
OMG, Carnac... I was looking for such a util for ages and all others sucked.. no idea how I managed to not come by it sooner! Thank you!
Donatas
Wednesday, 21 January 2015 08:53:31 UTC
That Phil Haack guy is so cool and dreamy.

-totally not Phil Haack. Unbiased observer.
Wednesday, 21 January 2015 09:05:20 UTC
Hm, my old Quake-style gravatar would have been more fitting.. :)
So, would this open a cmd prompt, or can it be configured to open a PoSh-prompt?
Wednesday, 21 January 2015 09:06:37 UTC
Frank - Of course!
Scott Hanselman
Wednesday, 21 January 2015 10:00:28 UTC
How did you record the gif? I'm using ShareX, but always looking for (better?) alternatives.
Wednesday, 21 January 2015 10:06:54 UTC
When you're in GitHub for Windows just press ~ and you'll automatically get a new command prompt


It doesn't work on a French keyboard (AZERTY). On those keyboards the upper-left key is '²' (not sure why someone thought we needed this character directly accessible). The '~' character is accessible through AltGr+2, but since it's a dead char, it doesn't work as a shortcut key...
Wednesday, 21 January 2015 10:21:21 UTC
So to open a console, you have to use...
~ in Quake
Alt+Space in VS
F12 in IE and Chrome

Life would be easier if all of them could agree to use a standard shortcut.
Stefan Offermann
Wednesday, 21 January 2015 10:23:57 UTC
I don't think 'Alt+Space' is a good key choice, as it just takes a shortcut that is reserved by Windows since at least 3.0: It should open the system menu, as it always did.
Bert Huijben
Wednesday, 21 January 2015 10:23:58 UTC
Thanks to Mats for building this extension! Installed.
Wednesday, 21 January 2015 11:23:01 UTC
And Microsoft should decide if we should use command line or PowerShell...
OnurG
Wednesday, 21 January 2015 11:34:38 UTC
I just discovered recently that ConEmu has a quake mode. It makes ConEmu appear from the top of the screen, and hides/show it with the Ctrl+` shortcut (as in Sublime Text). The shortcut is configurable.

You can see how to activate this mode here: http://tech.pro/blog/1239/conemu-quake-style-consoles
Melchior Corgié
Wednesday, 21 January 2015 11:52:24 UTC
Not working for me - The parameter is incorrect (Exception from HRESULT: 0x80070057 (E_INVALIDARG).

VS2013
John Francis
Wednesday, 21 January 2015 12:19:40 UTC
On UK keyboards its the `¬¦ key (top left, underneath the Esc key).
Richard Price
Wednesday, 21 January 2015 12:27:08 UTC
That key (tilde?) is not available on various international keyboards. For example as a kid, playing Quake, I could never try the various che... options, because I could not access the console.
El Dorko
Wednesday, 21 January 2015 13:06:16 UTC
Why do you need a command prompt at a project's location so often?
Jon
Wednesday, 21 January 2015 13:18:45 UTC
"A lot of people don't realize that you can Shift-Right-Click on a folder in Windows Explorer and you'll automatically get a "Command Prompt Here" menu item!"

Count me among them. Thank you so much.

(Not a great fan of non-discoverable features)
Rob G
Wednesday, 21 January 2015 13:27:21 UTC
@El dorko - see Richard Price's comment right above yours.
Rob G
Wednesday, 21 January 2015 13:53:15 UTC
Awesome!! Just installed works like a charm!

Great work Mad and Scott!!
Wednesday, 21 January 2015 15:12:43 UTC
I always opened a command prompt in a specific folder by typing cmd and pressing enter in the Explorer address box. So I'd right-click my project and Open Folder in File Explorer, then type cmd and press Enter in the address box. It opens the command prompt with the path set to the current folder.
Andy
Wednesday, 21 January 2015 15:22:02 UTC
Submitted a pull request to have an option to always open at the solution level if desired, hopefully he'll accept it, I can't think of a reason in my development why I'd want to be at the project level.
Chris
Wednesday, 21 January 2015 15:27:48 UTC
I'm using a conEmu prompt. If I make the command: c:\path\to\conemu\prompt it doesn't open in the project/solution directory. I've been trying to pass it the solution path via Command arguments with $(SolutionPath), but that doesn't seem to work. Any suggestions or thoughts?
Ben
Wednesday, 21 January 2015 16:38:54 UTC
I normally use WinKey+x -> a. Downside is it defaults to \windows\system32. Upside is it's running as admin. I also set it to launch powershell instead of cmd.
Dan Tower
Wednesday, 21 January 2015 16:43:37 UTC
Anything Scott, Phil and Mads like is cool, but you can already do the same with Visual Studio's "External Tools" in the Tools menu. I have a "CMD Here" item, mapped to Ctrl+`, which opens a command prompt to the path of the currently selected item (file, project, etc.). Using external tools, this would also get saved in your exported settings when moving to a new machine or upgrading to future VS versions. (The extension's settings may as well -- I don't know.)
Scott
Wednesday, 21 January 2015 18:43:31 UTC
@Ben - The extension forwards the directory path as the current working directory of a newly spawned process, rather than a token like $(SolutionPath). You can get the working directory of the ConEmu process with %ConEmuBaseDir% from within ConEmu, so you can use this to get your shell set. So, if you have a ConEmu task named "{PowerShell}", configure the extension to pass along
/cmd {PowerShell}
to the ConEmu64.exe. Then, within that task, have command simliar to
powershell.exe -Command "& %ConEmuBaseDir%"
and you should get your PowerShell process set to the correct directory.
Wednesday, 21 January 2015 22:03:52 UTC
@Andy i do the same thing, it works great! It also works for 'powershell' to :)
Thursday, 22 January 2015 01:18:01 UTC
wow, thanks for sharing
Thursday, 22 January 2015 01:36:24 UTC
The Productivity Power tools command extension has a open command prompt feature that opens a command prompt in the selected location. Although I don't Think you can map it to anything but cmd.exe
Niclas Lindgren
Thursday, 22 January 2015 12:51:05 UTC
1. How can I set to powershell ? ( https://visualstudiogallery.msdn.microsoft.com/4e84e2cf-2d6b-472a-b1e2-b84932511379 gives an error - however it can be installed in VS)

2. With which tool did you make the animated gif?

Thank you
Thursday, 22 January 2015 15:32:51 UTC
TIP: A lot of people don't realize that you can Shift-Right-Click on a folder in Windows Explorer and you'll automatically get a "Command Prompt Here" menu item!

Awesome tip ;)
John
Thursday, 22 January 2015 23:41:09 UTC
I always loved the Quake console as well.

On my Mac I use TotalTerminal to get the same effect.

I wish it were easy to get the same thing in Windows.
DWAK
Friday, 23 January 2015 12:54:33 UTC
As usual is a pleasure to read your blog.
Friday, 23 January 2015 15:22:16 UTC
I don't need a command prompt here very often but I do seem to want to open File Explorer here quite a bit. Good news is there's already an Open Containing Folder command in Visual Studio, I bound it to Ctrl+Shift+Alt+O (because every two-modifier-key combination with O is taken). From there, the shift-right-click, command prompt here is available.
Friday, 23 January 2015 19:17:31 UTC
+1 for leaving Alt+Space assigned to the System menu, like it has been for years and years, for every Windows application.

Am I the only one that regularly uses:

Alt+Space, x - Maximize window
Alt+Space, n - Minimize window
Alt+Space, r - "Restore" (Unmaximize) window
Alt+Space, m - Move window (For when the window somehow gets stuck offscreen and can't be reached with the mouse, and needs to be rescued using the keyboard.
Saturday, 24 January 2015 07:57:30 UTC
If you use Console or ConsoleZ, I recommend to take a look at this extension https://visualstudiogallery.msdn.microsoft.com/1460ab21-75be-49d0-900f-dfd538321424 from Grzegorz Kozub. Since I usually have several shells and prompts open at the same time in tabs this extension allows you to open them all at once or just a couple. You can create any keyboard shortcut you want for it too.
Juan Valenzuela
Saturday, 24 January 2015 16:58:03 UTC
This is useful - a question though, is anybody aware of a way to access the Git command line in VS2015 for the current Project..? Perhaps I can add it as an external tool and pass parameters, but I was wonderful if there was an extension for this that is a neater solution. Any advice appreciated...
Saturday, 24 January 2015 17:16:42 UTC
Ok, I should have looked closer... and found GitTools extension:

https://visualstudiogallery.msdn.microsoft.com/48c3e91e-d1d7-4bf9-84dd-d3b97e2d5922?SRC=VSIDE

Seems to do the trick!
Sunday, 25 January 2015 00:51:09 UTC
I know you are a fan of ConEmu and Clink so you might be interested in Cmder - http://bliker.github.io/cmder/

It's a nice re-packaging of ConEmu, Clink and MsysGit and it can be easily configured to be a Quake style console. It has themes and uses Monokai by default so it looks pretty(ish) from the start.
Tuesday, 27 January 2015 16:52:20 UTC
It is a good idea.
But, I can't use with Visual Studio Express 2013 to Web. I cried!
Leandro Souza
Wednesday, 28 January 2015 12:49:50 UTC
I use stexbar for windows explorer. It has a button to open a console in the directory you are in, cmd or powershell.



Also you can install it using Chocolatey cinst stexbar or choco install stexbar
Adam Wright
Thursday, 29 January 2015 05:48:09 UTC
Alt+Space is used by Launchy
Dmitriy
Friday, 30 January 2015 04:31:30 UTC
Sweet... Funny blogged about adding that as an external command with a hotkey last week or so: http://weblog.west-wind.com/posts/2015/Jan/09/Tip-Create-a-Visual-Studio-Menu-option-to-Open-a-Command-Window which is similar except it gives you a little more control over what to shell to (Console2 for me specifically).

But you know what would be even better - is have Console support in a window like WebStorm does. While it seems like a little thing, having the command window right within the IDE and maybe active in a side panel is really nice instead of hunting around on the desktop through 20 windows to find the CLI...



Saturday, 31 January 2015 16:24:13 UTC
I concur with previous comments about the functionality loss incurred by conflicting with the 25-year-old Alt+Space keyboard shortcut. I put an issue in GitHub that describes the concern.
Sunday, 01 February 2015 11:33:18 UTC
If you want to open the Git Shell installed by GitHub for Windows, set up the options as follows:

Command: powershell.exe

Command Arguments (single line):

-ExecutionPolicy Bypass -NoExit -Command .(Resolve-Path "$env:LOCALAPPDATA\GitHub\shell.ps1"); .(Resolve-Path "$env:github_posh_git\profile.example.ps1")
Monday, 02 February 2015 16:31:50 UTC
Also, in windows explorer you could use autohotkey script for this. Explanation here.
Friday, 06 February 2015 20:06:43 UTC
Be even more awesome if it opened it in a nice GUI style and it slid in and out of the top.. Instead of launching a new one every time ... And such :)
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.