
Run PowerShell as a shell within Emacs - rayvega
http://blogs.msdn.com/dotnetinterop/archive/2008/04/10/run-powershell-as-a-shell-within-emacs.aspx
======
peschkaj
This becomes a lot cooler, too, when you take a look at that PaSH project:
<http://pash.sf.net>

~~~
rufugee
Why, exactly? Why would I want Powershell on Linux?

If it's cross-platform scripting ability you're after, then why not focus
efforts on developing OS-layer abstractions that various scripting languages
which are _already_ cross-platform (perl, python, ruby, etc) can use? Given
that, what does Powershell offer that these don't?

~~~
trezor
What differentiates Powershell from general scripting languages is that it
_is_ intended as a shell and hence works somewhat close to the OS, the
filesystem, or whatever you are doing just now.

I can't speak for the author of Pash, but for me (and I like bash) is that
unlike in the typical Unix shells, you don't pipe and work with text, you do
it with fully fledged _objects_.

So needless to say (if you can get over the somewhat icky syntax) you can do
some very neat and powerful stuff with a minimum of effort.

Want to kill all processes starting with z? Easy.

    
    
        Get-Process | where {$_.Name -like "x*" } | kill
    

Want to kill the biggest memory offender on the system? Also easy.

    
    
         Get-Process | Sort-Object workingset -descending | Select-Object -First 1 | kill
    

Want to list all running services? Also easy, just filter:

    
    
         Get-Service | where {$_.Status -eq "Running" }
    

Want it exported to for instance csv? Sure.

    
    
         Get-Service | where {$_.Status -eq "Running" } | Export-Csv services.csv
    

Like I said. The syntax leaves something to be desired, but the concept of
piping objects is pretty powerful in a shell, and I like how you can add
providers, so you can use this with the filesystem, registry, database-
servers, whatever and just navigate it naturally and use the same syntax and
commands for most processing.

It may not be for everyone, but it certainly has its place.

~~~
rbanffy
So, it's like one of the couple dozen scripting languages with OS bindings
already available under Unixes, minus the readability...

I understand if one would want it under Windows, but it's not a step in the
right direction for anyone else.

How does the Export-Csv know what information you want to be exported?

~~~
gaius
The interesting thing about PowerShell is that you're not piping really
streams of text but COM objects. In a Windows environment this is pretty
slick. To give an example, in a traditional shell, you'd run a command, it
would do whatever it does, format it for output, then you would _unformat_ it
with awk or whatever so you could use it. In PowerShell, you get it
structured, eg it's

    
    
        mycommand2 `mycommand |awk '{print $2}'` 
    

vs

    
    
        mycommand|mycommand2 $_.myproperty 
    
    

Which is more readable? Which survives mycommand being enhanced with another
column of output? It doesn't make sense to use PowerShell on Unix because none
of the existing commands emit C structs, there's no way to get the output of
ps as struct after the pipe.

------
RyanMcGreal
That blog design is totally broken in Firefox maximized on a 1024x768 screen.

~~~
julio_the_squid
I found that in Firefox with any screen width less than the text + the two
sidebars, the sidebars overlap the text content. I tried it in IE6 actually,
and the sidebars don't show at all! Pretty lousy layout.

------
ax0n
We get it. emacs can do everything. C-x M-c M-Butterfly.

~~~
rbanffy
I have no butterfly key on my keyboard...

~~~
ax0n
<http://xkcd.com/378/> \- In geek circles that reference this particular
comic, most people write an emacs shortcut that uses M-b instead.

~~~
rbanffy
I can make the Windows key have a butterfly painted on it. I never quite
understood why I even had a Windows key on my computer ;-)

