Windows PowerShell 1.0 Command Line Editing

Retrieving and Editing previous commands

I was going to be critical about the command line editing features but after playing around with it I find that it has all the features I am looking for. I am not fond of having to use function keys to manipulate the history list because I am a ‘vi’ user and don’t like to leave the home row on the keyboard.

Powershell still can’t compare to Unix shells which allows the user to chose Emacs or VI commands to edit the command line.

There is one HUGE omission in the help file ‘about_history’ where it talks about using the F7 key to pull up the history list then F9 to prompt the user for the command number of interest to place on the command line for editing. The omission is that all one has to do is use the arrow keys to scroll to the command of interest then press either the left or right arrow key to move the command to the command line for editing. This makes all the difference for me.

Irregularities with the History list

Get-History does not show the current command in the list. Of course, the current command will always be ‘Get-History’.

Pressing F7 also brings up a history list and it does show the most recent command but it only shows 50 commands even though the default MaximumHistoryCount is 64.

Interim thoughts

I have Cygwin installed on my Windows machine so I have a Bash shell available to me and it is pretty powerful. I am having second thoughts about spending the time learning PowerShell but I am intrigued by the object oriented concept. I’m not so sure it is a suitable tool for the IT professional that is running around with his hair on fire. (I heard that on one of the PowerShell webcasts)


3 comments so far

  1. /\/\o\/\/ on

    You have 2 different history buffer,
    one from the console (f7), and one from Powershell

    h (get-history)
    r [linenumber] (invoke history)

    thats the one configured by $MaximumHistoryCount,
    in my custom tabcompletion function ( )
    I made 2 otherways

    h_a[tab] (loads al history (powerShell) starting with a )

    G_[tab] GUI historyselect (like F7 but in form and supporting multiline commands )


    Greetings /\/\o\/\/

  2. abdul on

    PowerShell *does* compare to UNIX shells because vi or emacs commands are not part of those shells. Just as most other famous commands. For example, you *can* use ced, grep, or any other GNU (or non GNU) shell command (well, as long as a Win32 .exe version is available). It’s just a matter of having them in your $env:PATH.

  3. Ken on


    The original article was comparing powershell to unix shells in the context of command line editing. Of course you can run grep/vi/emacs/etc under powershell. The point he was making was that most unix shells have subsets of vi/emacs *built in* to them to allow for quick command line editing. For example, to turn on “vi” command line editing, in tcsh you would say “bindkey -v”, and in ksh you would do a “set -o vi”…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: