有没有更好的 Windows 命令行 shell?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/722980/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 06:14:36  来源:igfitidea点击:

Is there a better Windows command-line shell?

windowsshellcmd

提问by skiphoppy

CMD.EXE is posing lots of problems for me. I have Cygwin installed and use bash regularly, and I also have the mingwin bash shell that comes with mSysGit, but sometimes I really do need to run things from the Windows shell.

CMD.EXE 给我带来了很多问题。我安装了 Cygwin 并定期使用 bash,我也有 mSysGit 附带的 mingwin bash shell,但有时我确实需要从 Windows shell 运行东西。

Is there a replacement for the Windows shell that:

是否有 Windows shell 的替代品:

  • has a persistent command-line history, available in my next session after I close a session? (as in bash HISTFILE)
  • remembers what directory I was just in so that I can toggle between two directories? (as in bash cd -)
  • 有一个持久的命令行历史记录,在我关闭会话后在我的下一个会话中可用吗?(如在 bash HISTFILE 中)
  • 记得我刚刚在哪个目录中以便我可以在两个目录之间切换?(如在 bash cd -)

(Or is there a way to enable these features in CMD.EXE?)

(或者有没有办法在 CMD.EXE 中启用这些功能?)

I see some has asked about a better windows shell before, but they were asking about cut and paste which is lower in priority for me at this point. It's not the console that's killing me, it's the command-line interpreter.

我看到有些人之前曾询问过更好的 Windows Shell,但他们询问的是此时对我来说优先级较低的剪切和粘贴。杀死我的不是控制台,而是命令行解释器。

采纳答案by Wouter van Nifterick

I've always liked 4NT (haven't used it for a while now).

我一直很喜欢 4NT(好久没用了)。

It's an enhanced command interpreter for windows, and it's mostly backwards compatible (meaning you can run normal windows batchfiles). The only reason not to use it is that it doesn't ship with Windows like the default command.exe does.

它是 Windows 的增强命令解释器,并且主要向后兼容(意味着您可以运行普通的 Windows 批处理文件)。不使用它的唯一原因是它不像默认的 command.exe 那样随 Windows 一起提供。

Compared to the default windows commandline interpreter, it has better flow control mechanisms. All standard windows commandline tools are available, but with extra options and parameters.

与默认的 windows 命令行解释器相比,它具有更好的流量控制机制。所有标准的 Windows 命令行工具都可用,但有额外的选项和参数。

Basically it's what CMD.exe should've been.

基本上它就是 CMD.exe 应该是的。

Update: looks like it's not called 4NT anymore, but TakeCommand: http://jpsoft.com/products.htm

更新:看起来它不再被称为 4NT,而是 TakeCommand:http://jpsoft.com/products.htm

回答by Seb

Microsoft's just released Powershell. (about 2 years ago)

微软刚刚发布了Powershell。(大约 2 年前)

I've already downloaded it; didn't try it much, but seems a nice tool.

我已经下载了;没有尝试太多,但似乎是一个不错的工具。

回答by boj

I'm using Powershell too. It's a great, linux shell-like but object oriented, extensible framework. Cool not for just system administrators but for developers too (build process etc.). Powershell rocks bash or other linux competitors:)

我也在使用 Powershell。这是一个很棒的、类似于 linux shell 但面向对象、可扩展的框架。不仅对系统管理员很酷,对开发人员也很酷(构建过程等)。Powershell 震撼 bash 或其他 linux 竞争对手:)

Main adventages:

主要优点:

  • Extensiblewith .NET languages
  • Use of .NET objects(DateTime, File etc.)
  • Easy and clear syntax
  • Remoting
  • Debug
  • Steppable pipelines
  • ...
  • 使用 .NET 语言进行扩展
  • 使用.NET对象(日期时间,文件等)
  • 简单明了的语法
  • 远程处理
  • 调试
  • 阶梯式管道
  • ...

More from here:

更多来自这里:

http://blogs.msdn.com/powershell/default.aspx

http://blogs.msdn.com/powershell/default.aspx

http://windowsteamblog.com/blogs/windowsvista/archive/2006/11/14/it-forum-day-one-windows-vista-and-windows-powershell.aspx

http://windowsteamblog.com/blogs/windowsvista/archive/2006/11/14/it-forum-day-one-windows-vista-and-windows-powershell.aspx

http://blogs.msdn.com/powershell/archive/2007/11/06/what-s-new-in-ctp-of-powershell-2-0.aspx

http://blogs.msdn.com/powershell/archive/2007/11/06/what-s-new-in-ctp-of-powershell-2-0.aspx

回答by sparrowt

Another brilliant solution is 'Clink' which enhances CMD.exe with persistent history and many more BASH-like features. Just install it and then open CMD as normal. See: http://code.google.com/p/clink/

另一个出色的解决方案是“Clink”,它通过持久的历史记录和更多类似 BASH 的功能增强了 CMD.exe。只需安装它,然后像往常一样打开 CMD。请参阅:http: //code.google.com/p/clink/

Or if you really want 'cd -' to work taking you to the previous directory then install 'TCC/LE' free version from http://jpsoft.comas mentioned by Wouter and Peter.

或者,如果您真的希望“cd -”能够将您带到上一个目录,那么请从Wouter 和 Peter 提到的http://jpsoft.com安装“TCC/LE”免费版本。

回答by Juande Carrion

PyCmdfits both of your requirements! And it's built on top of cmd.exe...

PyCmd符合您的两个要求!它建立在 cmd.exe 之上......

  1. the command history is persistent across PyCmd sessions
  2. history of recently visited directories (Alt-Left/Right/D on empty line)
  1. 命令历史记录在 PyCmd 会话中是持久的
  2. 最近访问目录的历史记录(Alt-Left/Right/D 在空行上)

Here you have the list of features http://sourceforge.net/projects/pycmd/files/pycmd/0.8/

这里有功能列表http://sourceforge.net/projects/pycmd/files/pycmd/0.8/

回答by mkoryak

try console2: http://sourceforge.net/projects/console/

尝试控制台2:http: //sourceforge.net/projects/console/

i like it

我喜欢

回答by driis

PowerShell, I would say. It is Microsoft's new official shell for command line administration.

PowerShell,我会说。它是微软用于命令行管理的新官方 shell。

I use it for development tasks myself, and like it. It gives you the flexibility to interact with the .NET framework classes directly on the command line, which can be very powerful.

我自己将它用于开发任务,并且喜欢它。它使您可以灵活地直接在命令行上与 .NET 框架类进行交互,这非常强大。

回答by spiralx

Others have mentioned Powershell and 4NT already, both are much better solutions than CMDand all its arcane syntax, lack of documentation and often-surprising inability to do almost any task you might want to use it for :)

其他人已经提到了 Powershell 和 4NT,它们都是比CMD其所有晦涩的语法、缺乏文档以及经常令人惊讶地无法完成几乎任何您可能想要使用它的任务都要好的解决方案:)

  • 4NT is now part of Take CommandGUI file-management suite, but the owners have made just the shell part available on its own, it's called TCC/LE now and is also now free! For most people I'd say to use this - it's the easiest learning curve by being having a mostly compatible syntax to CMD, having lots of resources online and being capable of doing say 80% of file system tasks perfectly.

    TCC/LE download

  • For people with more obscure needs, doing lots of administration, or want more flexibility, try Powershell - it's a steep initial learning curve, but it's internally very consistent and once you've figured out the basics you can access and operate on 99.9% of everything Windows handles using the same set of tools and methods, even executing it across a network on other machines. Even learning the basics (sort, select, % and ?) is better than CMDalready...

    PowerShell Owner's Manual

    PowerShell Examples

  • If you're more technically inclined then I'd consider IPython - at the core it's a console for writing and executing Python code, but it also acts as a shell (and task management system) very handily - it has bookmarks, aliases, tab completion of code/files, can mix code and shell commands e.g. files=!dir *.txtsaves the output of dir *.txt, configurable logging of input and/or outputs, can repeat blocks of past commands, export them or create macros, and has extensions which can customise it more.

    IPython as a shell

    Definitely not for the faint of heart, but a very powerful environment if you know Python!

  • 4NT 现在是Take CommandGUI 文件管理套件的一部分,但所有者仅提供了自己的外壳部分,它现在称为 TCC/LE,现在也是免费的!对于大多数人来说,我会说使用它 - 这是最简单的学习曲线,因为它CMD具有与 .

    TCC/LE 下载

  • 对于需求更模糊、需要进行大量管理或想要更多灵活性的人,请尝试使用 Powershell - 这是一个陡峭的初始学习曲线,但它在内部非常一致,一旦您了解了基础知识,您就可以访问和操作 99.9% 的Windows 处理的所有内容都使用相同的工具和方法集,甚至可以通过网络在其他机器上执行。即使学习基础知识(排序、选择、% 和 ?)也比CMD已经更好......

    PowerShell 用户手册

    PowerShell 示例

  • 如果你更倾向于技术,那么我会考虑 IPython——它的核心是一个用于编写和执行 Python 代码的控制台,但它也可以非常方便地充当 shell(和任务管理系统)——它有书签、别名、标签代码/文件的完成,可以混合代码和shell命令,例如files=!dir *.txt保存输出dir *.txt,输入和/或输出的可配置日志记录,可以重复过去的命令块,导出它们或创建宏,并且具有可以对其进行更多自定义的扩展。

    IPython 作为外壳

    绝对不适合胆小的人,但是如果您了解 Python,则是一个非常强大的环境!

回答by David Owens

pushd and popd can be used to navigate to and from directories.

pushd 和 popd 可用于在目录之间导航。

c:>pushd windows c:\Windows>popd c:\

c:>pushd windows c:\Windows>popd c:\

回答by Rene Saarsoo

PowerShell works quite well when you do your things in PowerShell way. For example when you want to mess around with .NET apps and Windows files. It works great for scripting as the syntax is a lot nicer than in Bash...

当你以 PowerShell 的方式做你的事情时,PowerShell 工作得很好。例如,当您想要处理 .NET 应用程序和 Windows 文件时。它非常适合脚本编写,因为语法比 Bash 好得多......

But when you want to work with some typical UNIX apps, then you can easily get into trouble when PowerShell converts all your LF line endings to CRLF (and don't even think about piping binary files).

但是,当您想使用一些典型的 UNIX 应用程序时,当 PowerShell 将所有 LF 行结尾转换为 CRLF(甚至不要考虑管道二进制文件)时,您很容易遇到麻烦。

Just my experience.

只是我的经验。