Monday, January 17, 2011 4:00:00 PM UTC #

Welcome to 2011. It smells terrific here!

The problem

You may not know it, but you have a problem. You’re using the standard Windows command shell. This is a problem.

image

The problems are manyfold and boring, so I’ll briefly summarize:

  • Cutting and pasting is a problem.
  • The cmd shell’s default history is 100 lines. This is a problem.
  • DOS’s autocomplete featureset predates the word intellisense. It’s bad.
  • DOS hates double-quotes. A lot.
  • DOS also hates the less-than/greater-than characters. Try this on: runas /user:PC\windersUser /password:”I believe in using long passphrases and good security etc and so forth so I’ll throw in some special characters, like double-quotes (“) and a bunch of other random stuff: <>file1"
    • I waxed a little eloquent on the point above, and could go into futher boring detail, but just take my word for it. DOS doesn’t do windows, and DOS doesn’t escape special characters. Ever.

The solution

junk1

The solution is to launch PowerShell. For the privileged few running Windows 7, it comes pre-installed. For the rest of us, minus the crazy dude still running Windows 2000 for security/paranoia reasons, PowerShell can be downloaded.

A small aside: the Start menu in Windows 7 is excellent. I don’t maintain icons on my desktop, the quick launch, pin programs to the taskbar, clicking through the Start Menu. I just tap the Windows key and tap in a few letters. For PowerShell, WINDOWS, “p” “o” “w”, then ENTER. That’s it.

I rarely use SlickRun nowadays.

Ahem. Onward.

So now I’m running PowerShell…now what?

You get:

  1. Better autocomplete, especially with file and pathnames.
  2. Better default settings, including an output history that stores $HUGE_NUMBER lines.
  3. A shell that doesn’t hate spaces and double-quotes, and by extension, you.
  4. Little neat things, like dynamic vertical and horizontal resizing, and…
  5. Easy cutting and pasting. Allow me to give a full tutorial below:

Cutting to the clipboard

junk1

Pasting to the PowerShell host

junk2 

It’s The Little Things

Tonight I’m working through the Ruby koans. I know, who cares. But I’m here to tell you that, though there’s not all that much difference tonight between using the cmd shell and the PowerShell host, there’s a few little things that add up. Here’s a little thing: just now, I made this simple, tiny improvement that combined the cls command and the “run the koans” command into one line, which made iterating through the Koans that much more easier. Re-running the koans is now as easy as UPARROW, ENTER:

junk3

Footnotes

I haven’t bothered trying Console2 yet.

I know cmd.exe is technically not the DOS shell. Technically it still has all the interpreter problems DOS 3.3 had, so I’m calling it DOS, plus the full name for the built-in shell is probably something like Microsoft Windows Command Shell 2011 for the Microsoft Windows 7 Operating System Administration Pack R2 (KB994112). I just made that up, but if you think the name is a total exaggeration, go research why we call “VSTO” by a four-letter acronym.

Running cmd.exe inside PowerShell (strictly for the lazy)

If you love everything I’ve said, but can’t summon the mental energy to learn remedial PowerShell, that’s okay. You can still gain some benefit from the PowerShell host running the DOS command shell! Just type “cmd<ENTER>” at the prompt, to roll into the land of LEGACY.

junk4

Categories: Awesomeness | PowerShell
Technorati:  | 
Monday, January 17, 2011 4:00:00 PM UTC  #     |  Comments [3]  |  Trackback
Monday, January 17, 2011 4:53:40 AM UTC
I'm confused. You keep saying PowerShell, but you described how copy-and-paste work in the original command shell.
Jonathan Allen
Monday, January 17, 2011 3:00:25 PM UTC
The cmd.exe shell is different from what I posted above. With cmd.exe, you have to right-click and select Mark first, then follow the steps above. The PowerShell host doesn't need these pre-steps.

Don't take this whole post too seriously. It all started with the small convenience (being able to run two commands on the same line), which reminded me of other conveniences (longer history, better pasting, window resizing, etc), and I chose to explain how to cut and paste on a whim. I'm not entirely sure why I decided to explain how to cut and paste...just go with it :)
Friday, March 25, 2011 7:45:26 PM UTC
If you don't need to run mouse-dependent MS-DOS code, you can enable a little thing called QuickEdit mode to do away with the Edit > Mark nonsense. Also, the caret is the escape character. It won't magically let you use invalid characters in filenames, but you can pass redirection characters as parameters. E.g. `echo foo^>bar' will send `foo>bar' to stdout instead of sending `foo' to a file named `bar'. Two commands on the same line? `foo & bar'. `bar' only if `foo' is successful (errorlevel 0)? `foo && bar'. `bar' only if `foo' fails (not errorlevel 0)? `foo || bar'. You can build success/failure pipelines and use parenthese to group commands. E.g. `foo && (bar & baz) || qux' means if `foo' succeeds, run `bar' and `baz' (synchronously); if `foo' fails, run `qux'. The Windows NT command processor does have a lot shortcomings--I want backquotes--but there you have it.
Trev
Name
E-mail
Home page

Comment (Some html is allowed: b, blockquote@cite, em, i, strike, strong, sub, sup, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview
Syndication

Search
Posts on this page
Categories
Sites I visit regularly
About

Powered by: newtelligence dasBlog 2.2.8279.16125

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

© Copyright 2012, Peter Seale

Send mail to the author(s) E-mail



Sign In