I am planning to write an object-oriented shell (based on Python). I have many ideas already. But before I am going to implement it, I want to inspire me by some existing shell.
What I basically mean by object-oriented:
I have read that the Windows PowerShell is somewhat like that (based on .Net). Though I am searching for some existing Linux/MacOSX shells.
Of course there is also IPython but it is not really intended as a Unix shell, i.e. piping stuff around is quite complicated.
Microsoft's PowerShell (Core), installed by default on modern versions of Windows, can be installed on Linux too. It's a really good tool, a bit long to warm-up, but once it's done it's really useful.
The features I really love in it is the filtering :
ls | Where-Object { $_.size -eq 0 }
who can be rewritten in the compact form
ls | ? { $_.size -Eq 0 }
and the transformation (followed by it's compact form ):
ls | Foreach-Object { $_.name -replace "\folderName","daba" }
ls | % { $_.name -replace "\folderName","daba" }
you can also easily create pipe filter within the shell language, which is a pretty neat feature.
Function concat()
{
Begin { $rez = ""; }
Process { $rez = $rez + $_ }
End { $rez }
}
ls | % { $_.name } | concat
The last expression list all files, extract the filename and concatenate them in a single string (it might be some commandlet to do that, but I don't remember the name).
Another important part of the PowerShell, is the introspection, you can query your object property/methods from the command line :
ls | Get-Member
Really useful to play with new objects, it's a bit more descriptive than dir()from python
[1]: http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With