Hacker News new | past | comments | ask | show | jobs | submit login
Run PowerShell as a shell within Emacs (msdn.com)
16 points by rayvega on Jan 5, 2010 | hide | past | favorite | 16 comments



This becomes a lot cooler, too, when you take a look at that PaSH project: http://pash.sf.net


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?


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.


I use PowerShell every day at work. I much prefer it to CMD and at one point I much liked the idea of piping live objects, but the more I use it, the more I don't think it makes sense. If I want to work with live objects, then I want to work with a proper programming language. In my shell, the file system is my object model. I want to work with the bytes in those files.


Shells that pass around objects can be useful, but I don't think Powershell is really a great example of one. As you point out, the syntax isn't particularly good, and whilst Pash might be different, I found Microsoft's Powershell implementation to be extremely slow and clunky.

I'm kinda liking Rush, a object-orientated shell written in Ruby. The syntax is a lot nicer, assuming you're into Ruby:

    processes.select(:cmdline => /^z/).kill
It also works a lot better with remote machines.

Powershell's main weaknesses, in my opinion at least, is that it doesn't handle remoting very well, and that it requires the user to learn a new syntax in order to use it. I really like learning new languages, but I don't see myself needing Powershell anywhere near often enough to warrant remembering its syntax.


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?


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.


Export-Csv will know that you want to export all publicly available properties (ie visible aspects) of the objects it is being fed. If you want to restrict it, you only need to use the select command to filter it down, ie generate new objects with only a subset of the information.

To modify my example to only export service name and descriptive name:

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


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


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.


Latest Chrome on Windows, too.


Perfectly fine on Safari. :)


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


I have no butterfly key on my keyboard...


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


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 ;-)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: