win cmd.exe in Vim tab - windows

I'm looking for Vim/gVim plugin to use Windows shell (cmd.exe) (executing commands, retrieving output) in separate tab/frame.
There are a lots of such solutions for Linux, but I'm unable to do it in Win...

Unlike Emacs, Vim is an editor, not an environment (thank Gawd :) and it is not (nor will ever be, according to what the developers have been saying for the past 20 years) designed to house a command prompt/shell in one of its buffers.
That being said, there are a couple of plugins that try to imitate that functionality. Some work better, some worse ... check'em out, and see what works best for you:
cmd.vim
Shell.vim
Conque
Just to add, I don't use any of the above - just found them on vim.org, so you're on your own from here on.

Related

PowerShell eye for the Bash guy

For someone who has been using bash for years, what's the quickest way to get productive with Microsoft's PowerShell? I've noticed my old friends ls and ps work, but sadly grep didn't. I could just man up and read through the piles of documentation, but I'm guessing there is a quicker path to productivity for someone with a long history of bash usage.
I don't know if it matters or not, but the reason I'm looking to get acquainted is because it seems like there is finally a proper shell on Windows instead of needing to install cygwin, and I'd like to start using it exclusively instead of writing bat files for automated activities like builds and deployments and such.
I'm not sure your Bash history is going to help you much with PowerShell. It is quite a bit different since the idea is to pipeline rich .NET objects as opposed to text or byte streams. For a leg up, check out my Effective PowerShell free eBook. It is about 60 pages but I think does a decent job of outlining the mental model you need to get the most out of PowerShell. For a full, free book check out Master PowerShell. At the point you think you're willing to part with some $$, Windows PowerShell in Action is the best book out there IMO.
Note: there are some "Unix" oriented aliases to get you by for a while (ls, ps, etc) but you'll run out of steam pretty quick because the parameters are quite different and as I said the pipeline is quite different than in Bash.
I would also recommended looking over some of the Q&A on PowerShell on StackOverflow especially for those questions that you think - "yeah, how would you do that in PowerShell". I think you would learn a good bit just doing that.
A quick Cheat sheet
​​​​​​​​​​​
I'd suggest just man up and read through the "piles" of documentation. It's actually not that difficult once you get the basics down. You'll need the knowledge anyway if you intend to do anything even remotely productive with PowerShell.
there GNU utilities such as your favourite grep that is ported to windows. see GNU packages
on the other hand, if you loathe the idea of downloading stuff, you can use vbscript. it comes natively installed.

Forcing myself to master Emacs

Assuming a superficial knowledge exists, how might one go about forcing a mastery of Emacs?
Assume also that said person currently uses Aquamacs but falls back on Mac OS X-isms far too often. This person is serious (this time for sure), and needs some advice.
C-h t
Take the tutorial, and actually follow it all the way through.
Then, learn some of the more useful time-saving functionality, like C-x ( to start recording a macro, C-x ) to finish, and C-x e to execute the last macro. Read the manual (C-h i m emacs RET) for more details. Try learning to browse through the documentation within info mode in Emacs, rather than resorting to the web, to get more used to how navigation works in Emacs.
Oh, and try using an Emacs that doesn't have the Aquamacs key bindings. There is a command line version of Emacs included on Mac OS X, though using the Meta key is a pain there (you have to either set your Terminal preferences to use Option as meta, or always use Esc). You can also use MacPorts to install an X11 version of Emacs, which won't have the Mac style keybindings.
Also, try using Emacs keybindings in other Cocoa text editing views. It's not something that a lot of people know, but a few common Emacs keybindings also work in the standard Cocoa text controls, such as C-a to go to the beginning of a line, C-e to go to the end, C-k to kill to the end of the line, C-y to yank from the kill buffer (which is different than the pasteboard). C-t transposes two characters, and I'm sure there are more that I can't think of at the moment. Using these on a regular basis will get your fingers used to Emacs keybindings (many of these also generally work in most shells, and in programs that use GNU Readline for being able to accept editable input).
For any technology you use on a regular basis, seek out the best Emacs mode you can for that technology, and learn it inside and out. For instance, if you're a Git user, I find Magit indispensable. If you program JavaScript, make sure you use Steve Yegge's js2-mode. If you use Common Lisp, learn SLIME, if you use Erlang learn distel. Sometimes, the best Emacs mode won't be the best tool you can find for a job, but for many, many things it's pretty good, and great to have it all integrated in to the same editor and environment.
Keep practicing everything you learn, over and over. I find that I frequently learn a new Emacs keybinding, and then promptly forget it because I don't use it for another 6 months. You can alleviate this problem by looking for any excuse you can to use a new keybinding after you first learn it, to help get it ingrained in your memory.
Don't use Mail.app, Gmail, or whatever -- use Gnus.
Don't use a web browser for programming information, use Info pages
where possible.
Don't use Terminal, use M-x shell.
Make sure you have a right and a left control key. I have a MacBook and have mapped the right option key to control.
Swap left control and capslock.
Read Steve Yegge's advice.
Find a killer app.
Always, always, always read the Emacs manual and use M-x apropos when you want to do something but don't quite know how. Emacs probably has the best online help of any program, ever.
I found the only way to master anything is to do it daily (practice, practice, practice).
As far as Mac OS X-isms... I'm not sure that's a problem per-say. Personally, in my quest to master Vim, I ditched Mac OS X entirely and have been happily living in GNU/Linux-land since.
Good luck!
Practice.
Try to answer questions here that are tagged Emacs.
Practice more.
Visit the Emacs Wiki and try ideas from it.
Practice even more.
Good luck!
Step 1: Notice you are doing something complicated.
Step 2: Read the manual to see if there's an easier way.
Step 3: Undo your changes.
Step 4: Do things the "new way".
Step 5: You've just learned one more new feature. Go to Step 1.
Switch to Carbon Emacs which doesn't have all the Mac bindings. It's a lot closer to the Unix Emacs experience but doesn't require X11 installed. The only real downside to Carbon Emacs is that Apple has no 64 bit Carbon and is probably phasing Carbon out, so Carbon Emacs might not have a long life ahead of it.

Resources To Learn About Batch Files

In my new project I need to use batch files(many of them), but now I need to know about they and where can I read some good tutorials to use they very good ;)
PS: I need to distribute my application for end-users.
Well, learning by doing is probably the best way. There are many pitfalls and weirdnesses in the batch language, making some tasks very much non-fun to do. But I think one should at least stepped into each trap once :-)
References are for example (sometimes with extensive examples for specific usage scenarios):
Rob van der Woude
SS64
Technet
Specific problems and solutions may be found on sites like Rosetta Code but there aren't many (and I still didn't get around cleaning up there; the batch examples are horrible). I maintain a few tricks on my own site as well (currently under maintenance, though; struggling with my syntax highlighter).
Others have mentioned it: If you have the option, then by all means use other technologies. PowerShell is a nice one but not included by default on older Windows systems, including Vista. For many more complex tasks VBScript via WSH is usually a better option as it has a similar installed base and is way more powerful.
Depending on your requirements this may or may not be possible, but take it into consideration if it may be an option.
While I usually don't like MSDN, in this case its documentation on batch files seems fairly decent.
Basically with bat/cmd files you are running DOS commands (with extra programs/features available to Windows) with each command on a new line.
The .cmd extension is prefereable to .bat on older Windows systems as it runs with cmd.exe, which executes faster than the older command.com. On newer systems (XP and above I think) then it doesn't matter if it is .cmd or .bat then they get executed by cmd.exe.
Here's some tips/examples on writing batch files:
http://www.ericphelps.com/batch/
Wikipedia has a list of DOS commands here:
http://en.wikipedia.org/wiki/List_of_DOS_commands
Here's some info on invoking the actual cmd.exe
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true
You can start with: Command Line = PowerShell / bash / zsh / ...
Batch is very old-fashioned and practically obsolete now.
The one thing I can recommend if you're working with batch scripts in Windows is learn PowerShell. It's a souped up command line that will allow you to interact with any .net object.
Have fun!
Besides everything that was suggested, I can recommend using VBScript (.vbs). To use Powershell, you need to install it (although it might be installed along with Windows Updates). To use VBScript (which is also very powerful) you don't need anything, it's in Windows by default.
On Windows, use Start|Help and Support Center, and search on "Using batch files", and then in the list of topics under "Overviews, Articles and Tutorials" in the Suggested Topics, click on "Batch files". You'll find links to using parameters, filters and redirection, as well as reference links for batch commands like CALL, ECHO, FOR, and so forth.
The one advantage of batch files over PowerShell is that PowerShell may not be installed, while the command processor (CMD.EXE, or the older DOS version COMMAND.COM) will definitely be there.

Programming a terminal emulator, what's in it?

This is related somewhat to this question about a better shell terminal/gui-interface for cmd.exe
In my quest to find a better shell terminal, the only useful thing I came across was Console2, other alternatives weren't free and generally didn't offer much more than Console2 to make them worth their price.
I can't help but wonder, "how come"? The shell terminal is a very valuable tool to a programmer, yet no one came around to try and do a better job than cmd.exe (except for the guys # console2)??
Surely designing a command line shell terminal emulator can't be such a hard task!
Has anyone tried writing a shell terminal emulator before? What's in it? Any resources out there (say, if I want to program my own shell)?
UPDATE
17/07/2009
I rephrased the question, what I was referring to as a "shell" is actually called a terminal emulator (at least in the linux world). I only realized this recently so I thought I should revisit this question and fix it.
There are plenty of shells around for Windows, bash under Cygwin is the one I use the most, and it's certainly free. I have to be honest here, cmd.exe has come a long way since the batch file processor of MSDOS. It's actually quite powerful, but still not a pimple on the rear end of bash :-).
You should try to write a command line shell, it will be an education for you. It's not that hard to do the basics if all you want is a program launcher.
But, if you want all the power of a real shell, including a full blown programming language, job control, piping, output redirection and (seriously) too many other things to list, we probably won't be hearing from you for a while. Except when you pop up your head to ask us esoteric questions about how shells should do this or that.
What about PowerShell from Microsoft? AFAIK it's free, and gives you C# power right in the shell, and tons of other features. But, it DOES require the NET Framework...
I won't endorse it yet, as I haven't really used it, but it's on my list to do...
My bets are on Powershell for the future if you are a Windows guy.
PowerShell will be installed by default on Windows Server 08 R2 (WS08R2) and Windows 7 according to MS.
I have used Powershell myself and found it to be very useful, and if you are familiar with .NET then its all the more easier.
Download a two page reference document here, this is all you will need to get started.
I mean the gui-interface part that displays the text,
Ah! you mean what we call a "pseudo-tty" or a "terminal emulator" in unix. In windows, I guess it is called a "console host". I do not use windows, but I heard that console2 is very good.
Seems there are others:
http://www.powershellanalyzer.com/
http://powershellide.com/
http://www.codeplex.com/PoshConsole
and, of course, for real programmers, you have the shell mode of (x)emacs :-)
Erm... what about all the ports of Unix command shells to Windows?
Just go with cygwin and log on using PuTTY. So much better than the standard console. :)
Also, Python (or perl for that matter) can replace the shell entirely.
You might want to try Take Command Console, formerly 4NT, formerly 4DOS.
Quick summary of points you might care about:
Command line editing with filename completion, history, and cut & paste
Integrate PERL, Ruby, REXX, Python, and any Active Scripting language
Fast - 20-200% faster output display than the standard Windows console
Integrated file explorer - examine directories, drag and drop files
Upwardly compatible with CMD.EXE with literally thousands of additions
Not free (except trial version) and not open source. I haven't tried it myself, but I was a 4DOS junkie back in the day, before Cygwin.
If you need handy terminal - give a try to ConEmu (I'm the author). It is a Windows console window enhancement (local terminal emulator), which presents multiple consoles and simple GUI applications as one customizable tabbed GUI window with dozens of features.
Another answer and comments

Where can I find a graphical command shell?

Terminals and shells are very powerful but can be complicated to learn, especially to get the best out of them. Does anyone know of a more GUI based command shell that helps a user or displays answers in a more friendly way? I'm aware of IPython, but even the syntax of that is somewhat convoluted, although it's a step in the right direction.
Further to this, results could be presented graphically, e.g. wouldn't it be nice to be able to pipe file sizes into a pie chart?
Hotwire is an attempt to combine the power of the traditional command line interface with GUI elements. So it has a GUI side, and tries to be helpful in suggesting commands, and in showing you possible matches from your history. (While there are keyboard shortcuts to do this in bash and other shells, you have to know them ...)
You can use all your common system commands, but a number of key ones have new versions by default which use an object pipeline, and are displayed with a nice GUI view. In particular ls (aka dir) shows lists files and shows them in columns. You can sort by clicking on the column headers, double click on files to open, or double click on directories to move to that directory. The proc command allows you to right click on a process and one of the options is to kill it.
The object pipeline works in a similar way to Microsoft Powershell, allowing commands in the pipe to access object properties directly rather than having to do text processing to extract it.
Hotwire is cross platform (Linux, BSD, Windows, Mac), though it is at an early stage of development. To learn more, install (click on the link for your platform) and work through the simple getting started page.
If you don't like hotwire, you could also look at the list of related projects and ideas maintained on the hotwire wiki.
fish is a Unix shell that focuses on user-friendliness, such as by providing colored highlighting and extensive tab completion.
For a different kind of blend of textual and graphical interface, there's Quicksilver, as well as similar/inspired tools like Launchy, GNOME Do and ENSO.
Is this for Python in particular, or are you just interested in any command shell that has a GUI interface?
If the idea of piping file sizes into a pie chart interests you, you might try PowerGUI, a GUI layer on Microsoft's PowerShell command shell. PowerShell also lets you pipe data from commands into XML, CSV, and other formats that are understood by GUI programs.
GUI-based command shell seems like an oxymoron to me.
Not really? A command shell is just an encapsulated environment in which to execute commands. Why can't they have GUI extensions? We are in the 21st century! :)
Check out http://hotwire-shell.org/
This is along the lines of what I was thinking. It's a shame it uses PyGTK, I'd have preferred PyQT (perhaps a licensing issue?). There look to be some interesting related links from the project as well.
If the idea of piping file sizes into a pie chart interests you, you might try PowerGUI, a GUI layer on [...]
PowerGUI looks like a hobby project I've been working on that organises regularly used tasks. It looks like it organises frequent jobs and formats the output for you. The formatting I see as the end result of the data flow. But it would be nice to be able to tinker with data and then continue to use it.
PowerShell as a command shell is very forgiving for new users and is easy to learn. There is an add-on product (it is a commercial product) called PowerGadgets that would let you pipe file sizes into a pie chart or other types of displays
PowerGadgets looks very interesting. It would be interesting to have things like system monitors so that you could say, read the CPU usage per second and pipe it into a graph.
Is this for Python in particular, or are you just interested in any command shell that has a GUI interface?
Any really, currently, but I like the idea of cross platform, easy to edit, no compiler setup. I use Windows at work and Windows/Linux (Ubuntu)/OSX at home. Python is just an easy solution, and for writing stuff like this is has a lot of libraries already.
Thanks for all the links. Keep them coming. :)
I'm not sure whether you're asking for a shell as in bash/csh, or a shell as in ipython. If it's the later, then I'd recommend looking at Reinteract. While it's still very alpha, it's already a great tool for rapid prototyping in python, and allows embedding of plots, widgets, etc.
GUI-based command shell seems like an oxymoron to me.
The key-word here is Graphical.
If I want a GUI, I want a full-featured GUI. But if I want raw performance, I want a command line.
I'm not exactly sure what you're asking for. You can either have a GUI or a command line. What do you need from a graphical command shell that you couldn't get from a straight GUI?
Also, if you want graphical information about file sizes there are a few applications that do that. One example is WinDirStat.
Also not related to Python, but Ubiquity (a firefox extension) is a graphical command-line-like tool for the web, with a similar spirit to Quicksilver/Launchy/GnomeDo.
I know that Automator in Mac OS X is not a shell but it is the best graphical tool I have ever used to do batch tasks. I think it is worth mentioning here as even I (self-titled as a power user) use it from time to time to rename files or other routines. Although these could be done in a few lines of shell script, the Automator's graphical interface makes me feel like I am not working and it just works.
Check out http://hotwire-shell.org/
PowerShell V2 is developing a graphical command shell, but I don't think that is what you are looking for.
PowerShell as a command shell is very forgiving for new users and is easy to learn. There is an add-on product (it is a commercial product) called PowerGadgets that would let you pipe file sizes into a pie chart or other types of displays. Information about that can be found here.
As for ease of use, PowerShell command follow a Verb-Noun pattern (along with aliases for ease of use from the command line) and is very discoverable. Check out some screencasts I did on using PowerShell at PowerShell Basics.
I found POSH, a GUI for MS PowerShell. This is pretty much what I intended. You have a command-line backend with a WPF GUI frontend. You can pipe results from command to the next and show graphical output.
Maxima provides a mathematical shell (screens) . It is nice that you type in a C-like syntax and receive graphically formatted output.

Resources