Scott Hanselman

Windows 10 gets a fresh command prompt and lots of hotkeys

October 01, 2014 Comment on this post [50] Posted in Tools | Win10
Sponsored By
image

Much has been written and much will be written about the Windows 10 announcement.

I'm pretty stoked, and am playing with the Windows 10 Technical Preview now. I can see that there's lots of new enhancements to the shell, the Start Menu/ Screen, how Universal apps work, and so much more. But, let's focus on the "other shell." The console!

The console (conhost) that cmd.exe (often incorrectly but colloquially called the DOS Prompt) and PowerShell live within hasn't had much love in the last several years, IMHO. But then, suddenly, on stage at the Windows 10 announce we've got a VP showing folks that Ctrl-V (paste) works in the command prompt. Why would he do such a crazy thing?

Well, from what I can tell looking at the Preview, there's a LOT of cool Console goodness coming in Windows 10.

Here's a list of hotkeys in the Windows 10 Technical Preview console. This is just hotkeys! Be sure to explore the Properties dialog as well, resize, word wrapping, and more.

Text selection keys

These combinations interoperate with the mouse so you can start selecting with the mouse and continue with one of these commands, or vice versa. 

Selection Key Combination

Description

SHIFT + LEFT ARROW

Moves the cursor to the left one character, extending the selection.

SHIFT + RIGHT ARROW

Moves the cursor to the right one character, extending the selection.

SHIFT + UP ARROW

Selects text up line by line starting from the location of the insertion point.

SHIFT + DOWN ARROW

Extends text selection down one line, starting at the location of the insertion point.

SHIFT + END

If cursor is in current line being edited

* First time extends selection to the last character in the input line.

* Second consecutive press extends selection to the right margin.

Else

Selects text from the insertion point to the right margin.

SHIFT + HOME

If cursor is in current line being edited

* First time extends selection to the character immediately after the command prompt.

* Second consecutive press extends selection to the left margin.

Else

Extends selection to the left margin.

SHIFT + PAGE DOWN

Extends selection down one screen.

SHIFT + PAGE UP

Extends selection up one screen.

CTRL + SHIFT + RIGHT ARROW

Extends the selection one word to the right.

CTRL + SHIFT + LEFT ARROW

Extends the selection one word to the left.

CTRL + SHIFT + HOME

Extend selection to the beginning of the screen buffer.

CTRL + SHIFT + END

Extend selection to the end of the screen buffer.

CTRL + A

If cursor is in current line being edited (from first typed char to last type char) and line is not empty and any selection cursor is also within the line being edited

Selects all text after the prompt.  (phase 1)

Else

Selects the entire buffer.  (phase 2)

Extra Fun with CTRL + A

CTRL + A behavior is interesting. Regardless of the state of mark mode and quick edit mode, one of two things should happen. Either the entire buffer is selected, or (only in a single case) '2-Phase select' starts.  2-Phase select is the process where the first CTRL-A selects the characters to the right of the edit line prompt, and the second press selects the entire buffer.

Editing keys

As I mentioned above you can copy and paste text with the keyboard. When copying text, you might worry that CTRL + C has always been the BREAK command. This is a nice touch, it will still send the break signal to the running application when no text is selected. The first CTRL-C copies the text and clears the selection, and the second one signals the break. Nice attention to detail, IMHO.

Editing Key Combination

Description

CTRL + V

Paste text into the command line.

SHIFT + INS

Paste text into the command line.

CTRL + C

Copy selected text to the clipboard.

CTRL + INS

Copy selected text to the clipboard.

Mark mode keys

These keys function in mark mode. You can enter this mode by right-clicking anywhere in the console title bar and choosing Edit->Mark from the context menu as before, or via the new shortcut combination, CTRL-M. In the original console, mark mode resulted in block mode text selection. While in mark mode, you can hold down the ALT key at the start of a text selection command to use block mode in the new console. The selection key combinations above are all available in mark mode. CTRL + SHIFT + ARROW operations select by character and not by word while in mark mode.

Mark Mode Key Combination

Description

CTRL + M

Enter "Mark Mode" to move cursor within window.

ALT

In conjunction with one of the selection key combinations, begins selection in block mode.

ARROW KEYS

Move cursor in the direction specified.

PAGE KEYS

Move cursor by one page in the direction specified.

CTRL + HOME

Move cursor to beginning of buffer.

CTRL + END

Move cursor to end of buffer.

History navigation keys

Navigation  Key Combination

Description

CTRL + UP ARROW

Moves up one line in the output history.

CTRL + DOWN ARROW

Moves down one line in the output history.

CTRL + PAGE UP

Moves up one page in the output history.

CTRL + PAGE DOWN

Moves down one page in the output history.

Other keys

Other Key Combination

Description

CTRL + F

Opens "Find" in console dialog.

ALT + F4

Close the console window, of course!

If you are like me and also love the console and want it to get even better, head over to the Windows Command Prompt Uservoice and be heard!

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service
October 01, 2014 22:16
This is just hotkeys! Be sure to explore the Properties dialog as well, resize, word wrapping, and more.


Does this mean real-time resizing of the dialog without going into settings and having the terminal resize as well? Please say yes.


October 01, 2014 22:21
Great info.. Thanks Mate!
October 01, 2014 22:23
Scott, would you wait for 10 or go to 8.1 soon, to get a taste of it, before 10 arrives? I have Win7 pro on my Lenovo with upgrade to 8.1 available. Admittedly, Win7 works perfectly for me, but now I'm wondering if I shouldn't get on 8.1 sooner.

Thanks! Love your tweets and blog, man!
October 01, 2014 22:46
I just found this one today and I like it. I'm not sure which version of Windows it was introduced with, but in cmd and powershell if you have history in that window you can hit F7 and menu pops up that lets you see your previous command line operations and you can select them. Similar to up and down in the command line, but with a little gui.
October 01, 2014 22:53
yah, it's inexplicable (at least to me) why there's so many new shortcuts to the command window in Win 10

I use it quite a bit as an IT guy but I can't imagine many others even knowing that it exists...

I think it was Win 7, where F2 on a file, selected the text of the file without the file extension...Anyway, that was worth the upgrade for me right there :)

Looking forward to Ctrl + V

Taki
October 01, 2014 23:13
Since the introduction of PowerShell (which has been an amazing addition to the platform), I've always wondered if/when Microsoft would replace what we know as the cmd.exe with PowerShell. From a user experience perspective this seems logical to me.

There are few things that I run directly within cmd.exe. PowerShell has overwhelmingly taken its place.

Windows 10 doesn't seem to be replacing cmd.exe, just giving it a face lift. Is that everyone's take so far?
October 01, 2014 23:34
David Studer - That F7 history was added in DOS 4.0, as I recall. Really.
October 01, 2014 23:50
@John Hargrove
yes, i just verified it myself :)

Also, if the hotkeys are not working, you migh have to go into properties and then the experimental tab and enable all the new stuff. i suspect they were not enabled by default for me because i upgraded an exsisting win 8.1 install. (this worked flawlessly by the way, all apps works including desktop ones, VS, gdrove, dropbox, everything)
aL
October 01, 2014 23:51
Word wrapping is my favorite so far, plus it's now dynamic as you resize the window
aL
October 02, 2014 0:30
aL,

Thank you. I just installed the preview and saw it myself. Living in the future!
October 02, 2014 0:50
Big smile. Very happy about the direction Windows Two (10) is taking. ;-)
October 02, 2014 0:53
The considerably different behaviors of Ctrl+C depending on whether there's a selection or not makes me nervous.

I'm sometimes in the habit of hitting Ctrl+C to clipboard copy multiple times in a row, due to some old application or PC -- don't remember which at this point -- that had a bad habit of not actually performing the copy on the first Ctrl+C press. Guess I'll need to break that habit!

It'll be weird, but nice, not having to do Alt+Space,E,P to do a clipboard paste in the console anymore!
October 02, 2014 0:57
Well the real improvement I have been waiting for, and not sure if it's included in the new enhancements, is the ability to keep history from previous console sessions. Linux has the ability to do this but in all this time the buffer of the command prompt is flushed when you exit the session...
October 02, 2014 1:13
Does it persist your command history between sessions? /want
Dan
October 02, 2014 1:27
Still waiting for 'set -o vi' support.
Ben
October 02, 2014 1:36
I think I read about clink on your page years ago, and have been using it since.
October 02, 2014 2:29
@John apparently it does, I tweeted a post from Rafael Rivera that covers some of the other features https://twitter.com/lavinski/status/517118565871140864
October 02, 2014 3:24
@Scott Hanselman Since DOS 4.0!!! Ok, I feel sheepish. Now I feel like I should remove my pocket protector and hand in my nerd badge. I still like it though.
October 02, 2014 5:54
The biggest thing missing from the windows command shell is persisting command history across sessions (shell / machine restarts)
October 02, 2014 6:27
Who uses CMD.exe anyway? Between Conemu and the numerous shells it can manage - git bash, TCC/LE, Powershell, etc... I haven't cracked open CMD in ages.

October 02, 2014 7:10
@Scott Saad: it's a facelift for conhost, the console host window -- this improves both PowerShell and CMD (and wmic, netsh, wmic, etc.) also. It's not really touching cmd.exe (at least, not so far).


Also, @Scott, you missed Ctrl+X (which oddly, copies, even in the prompt bug here) and Ctrl+Backspace (which isn't new, but ought to be on the list for completeness sake?)
October 02, 2014 7:47
To be honest, I was more impressed with ability to resize the window and have the contents wrap correctly. Hotkeys are nice too... I'm just so used to the way the console host does things that it just doesn't irritate me any more.
October 02, 2014 8:00
Hope they kept F7
October 02, 2014 9:30
Have they finally changed the god awful backspace path separator to forward slash? This got to be the #1 most annoying thing about Windows ever. And it gets even worse when you have spaces in your folder names. 40 years and it still can't beat the ole * nix prompt
October 02, 2014 12:47
I just installed the technical preview on a Hyper-V machine, and I don't have any of those hotkeys in the command line over there. Am I missing something? Will it be available in future previews only?
October 02, 2014 13:43
OK.
I just got my VM into our domain, and logged in using my domain user, and the command line now works as mentioned in this post.
For some reason it seemed like the good old command line in the other user (using a Microsoft account for login). I wonder why there is such a difference.
October 02, 2014 14:03
Finally shell gets an update.
I hope it saves me from jumping to Ubuntu.
October 02, 2014 16:52
i'm curious as to what convinced the Windows team to spend some time on the command prompt. i figured that as *the developers of Windows* they would be using the command prompt enough to fully experience its pain points ("You mean CTRL-V doesn't paste, like everything else in Windows?").

Does anyone have any ideas of why this would get attention now? Is it part of their marketing effort to reach out to enterprise-y customers?

As someone who breaks into powershell almost daily, i'm excited to see it improve!
October 03, 2014 2:20
No. Doskey was only since DOS 5.0. So don't feel so bad @Davin Studer... ;)
October 03, 2014 4:30
Still waiting for delete key in IE URL edit field to not go to the prior web page visited. It's a text editing field.

cmd.exe - still a compelling reason to use it for this instead of RE:
findstr /S /I /P pattern | findstring /i abc | findstring /v def | findstring /v ....

October 03, 2014 8:50
Does the new conhost finally show complex scripts?
October 03, 2014 13:03
Will we get 256 colors and ANSI/VT100 color support so that terminal vim and other (bad ports of) linux tools become usable?
October 03, 2014 17:23
Yeah, finally. That are really great news.
October 03, 2014 18:24
This is very, very long overdue. It really should have been done alongside the initial introduction of Powershell; here we have a command-line shell which lives up to the "power" name, good enough to be worth using for a lot of tasks, but it's been hobbled since its inception by probably the worst console I've used in any desktop OS.

Glad they've realized that there is a place for a usable command line in a modern OS.
October 03, 2014 20:32
I'm experiencing very buggy issues with fonts and window size on a Surface Pro set to 150% scaling. Every time I open Properties, the window size and font seems to change... and it doesn't seem to really respect my selections. I'm sure it's a display scaling issue though, as most people run at 100% and most people aren't reporting any issues. But click the layout tab and change the font or window size, hit OK, and things get weird.

The "transparency" feature is also interesting.
October 04, 2014 0:17
Also good to note that the ^ commands (^C, ^A, ^V) continue to work as normal when their new behavior doesn't make sense (CTRL+C still aborts if you don't have a selection), and that you can always get the old behavior of ^KEY by doing CTRL+SHIFT+KEY.
October 04, 2014 0:22
Bad example -- CTRL+SHIFT+C doesn't do anything special. This works for ^A, ^V, and ^F.
October 04, 2014 17:41
Hi Hansel man, seems you are missing hot keys to increase or decrese the Opacity
Ctrl + Shift + Plus
Ctrl + Shift + Minus
key combination does it, even when "Enable experimental console features" is set to off.
October 06, 2014 5:37
Cue hundreds of confused people wondering what the hell "conhost" is since "powershell runs in a cmd window."
October 06, 2014 19:35
Is there a way to request features for core windows features like file explorer? I hate having to install shell replacements (to get dark backgrounds, tabbed interfaces, jumplists, locked tabs) or having to use clipboard history managers like Ditto.
October 07, 2014 12:04
I can't tell if it's more funny or sad that (nearly) all the Linux weenies so far don't know the difference between the terminal / console and the shell / command prompt. (I say as a Linux weenie). Probably sad, since it happens every single time, Scott even pointed it out in this post.

I put this on my Surface pro 2, but I've not had much chance to play around with it yet. I'm interested to see if there are any new apis for being able to write a console replacement (or other rehosting use cases, for example a terminal pane in an IDE.)
October 07, 2014 13:50
You can have a lot of this, if not all (e.g. the Ctrl+C behavior), in the classic conhost with the PSReadLine Powershell module. Plus the command history persisting between sessions, Emacs & custom shortcuts or syntax highlighting.
October 09, 2014 18:20
Just installed the win 10 preview (did a new install over an old install, so I have windows.old, etc.) and the command prompt is acting exactly the same. None of the new features talked about here are working.

I did just clean out some adware, maybe that has something to do with it.

DOS prompt is saying:

Microsoft Windows [Version 6.4.9841]
(c) 2014 Microsoft Corporation. All rights reserved.

Is that right for the win 10 preview build?
October 11, 2014 0:02
What happens if you type in the following text?


env x='() { :;}; echo vulnerable' bash -c "echo this is a test"

October 16, 2014 0:33
Hi Bryan,

Make sure you go into cmd's properties and the "experimental tab" and turn on the new keyboard shortcuts and opacity.

Hope this helps!
November 15, 2014 14:20
Great News!!!!!!!!!!!!!!
November 19, 2014 13:09
Great list of shortcut keys Hanselman. I'm saving this list of shortcut and hotkeys in advanced so the task is more easier whenever I upgrade my system to Windows 10.
December 05, 2014 21:14
Scott nice tutorial tnx.
how toget offline preview builds of windows technical preview .
December 17, 2014 14:57
very nice
December 24, 2014 23:32
Microsoft has also released a new Windows 10 preparation tool for Windows 7 and 8 users.

Comments are closed.

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