/\/\o\/\/ PowerShelled

This blog has moved to http://ThePowerShellGuy.com Greetings /\/\o\/\/
$AtomFeed = ("Atom.xml")
$PreviousItems = (" MSH Scroll-host function "," Series about Monad on Computerworld "," Watching FSRM Quota and filescreen events from Monad "," More ACL and MSH on MSH for Fun "," Jelle "," Monad and "Jeugd sentiment" "," Monad Beta 3 Docs changes "," Get SpecialFolder Locations in Monad "," Filling Emty Properties in AD from MSH "," First Monad B3 impression and please help the scri... "," ")

Friday, January 20, 2006


Commandline editing with MSH.

There is a discussion going on now, and has been before at the newsgroup about the Commandline editing posibilities in MSH,

MSH runs on the cmd.exe console(at least till V2), hence has the same capabilities and limitations, and yes they are a bit oldfasioned and limited as CMD.exe was neglected a (whole) bit (to much) in windows.

And now with the power of MSH on the Commandline, we notice that even more, the Monad team has also pointed this out as a high priority for V2 in the NG.

but still I think CMD console is not as limited as most people think.

so I will give some tricks I find handy here,

I hear a lot of complains about the Cut-and-Past handing in the Console, but I realy love it ;-)
but not in it's "standard" form, I set it in Quick-edit Mode, It's realy the first thing I do change.

The complaint is the Ctrl-C ctrl-V does not work, you need to use the mouse to choose copy or Past from the Menu.

or you can use the keyboard shortcut

Copy :
Alt-Enter -> E -> (Y or Enter)

Paste :
Alt-Enter -> E -> P

As the scrolling Example, I made a work-a-round function for in last post, MSH Scroll-host function , (I Edited it, to remove the Key-echo workaround) that's not very handy

But here there is a better solution this time , setting QuickEdit Mode :

And while I'm at it, I also set the Buffer and Window Size.
set the buffer to 9999 (ignore the warning) to keep a long history of output.

Now you can just left-click and drag to select, and just right-click to paste.

that's what I realy like, while writing a script I do this a lot to past tested lines to Notepad.

also in MSH I just paste complete scripts to the console. (that get's it in my history also)
MSH will Nicely parse them, anly look out for Tabs in the Pasted code they will be parsed as typed so this wil trigger Tab-Completion !!
this will give very strange effects, but I never use tabs in my code so it's not a problem for me, only sometimes when I past in "Strange" code from somewhere that does.

another Tip I want to mention is using the function key's and arrows.

try F7 this will give a list of the command history,

In this Image you see the List shown as you press F7 in the console.
you can use the arrows and page-up page down to walk, Enter to run the Line and Right-arrow to just copy the line to the console.

Also note that in this session, I First tested a single line of the script of last post, when it was OK I pasted it to notedpad, and Just pasted the whole script back into the MSH shell to test.

also all the variables are in the Global scope (as MSH does think I did type them) so I can chack the values or paste in parts of the code again when I changed variables)

the QuickEdit Mode makes this very Quick and because can select rectangles in MSH you can leave out the prompt.

I love this way to work.

only gotha is for example a foreach
you can not do this
$a foreach
"do something"

as when you work "interactive" (as we fake this by just pating code in) you need to provide the { on the same line

$a foreach {
"do something"

so thats why you see me do that a lot in my code, it's a bit less readable but much more handy in testing as the last example I can just past on the commandline to test.
for the first example I need to save the textfile and run the script.

then if you have to change a past of the current command you can use use delete, change the part of the line and use F1 or the right arrow to fill it on with characters of the old line, this is very handy also.

So you see,
QuickEdit needs some getting used to, but if you get the hang of it, its very easy to work with.
or even can't live without it again (I would not want to change it for Ctrl-C / crtl-V).

and there are also some handy shortcuts for editing lines in CMD
(try the other Function key's but most you can do also with the arrows)


gr /\/\o\/\/
Tags :

Anonymous Anonymous
shouldn't that be alt-space?
Post a Comment

<< Home


October 2005   November 2005   December 2005   January 2006   February 2006   March 2006   April 2006   May 2006   June 2006   July 2006   August 2006   September 2006   October 2006   November 2006   December 2006  

$Links = ("PowerShell RC1 Docs"," PowerShell RC1 X86"," PowerShell RC1 X64"," Monad GettingStarted guide"," Monad Progamming Guide"," Monad SDK"," Monad videos on Channel 9"," MSH Community Workspace"," scripts.readify.net "," MonadSource"," www.reskit.net"," PowerShell Blog"," Under The Stairs"," computerperformance powershell Home"," proudlyserving"," MSH on wikipedia"," MSHWiki Channel 9"," Keith Hill's Blog"," Precision Computing"," PowerShell for fun"," MSH Memo (Japanese)"," monadblog")

find-blog -about "PowerShell","Monad" | out-Technorati.
find-blog -contains "","" | out-Technorati.
Web mow001.blogspot.com

This page is powered by Blogger. Isn't yours?