Programming a terminal emulator, what's in it?

2020-03-25 07:00发布

问题:

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.

回答1:

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...



回答2:

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.



回答3:

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.



回答4:

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



回答5:

Erm... what about all the ports of Unix command shells to Windows?



回答6:

Just go with cygwin and log on using PuTTY. So much better than the standard console. :)



回答7:

Also, Python (or perl for that matter) can replace the shell entirely.



回答8:

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.



回答9:

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