帮助我让我的 windows cmd.exe 控制台更像一个 Linux 终端

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/473839/
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 05:58:29  来源:igfitidea点击:

Help me make my windows cmd.exe console work more like a Linux terminal

windowslinuxshellterminalcmd

提问by Salim Fadhley

The windows terminal (the user-interface around text-applications like cmd.exe) really sucks.

Windows 终端(围绕像 cmd.exe 这样的文本应用程序的用户界面)真的很糟糕。

There is so much that the Unix-style terminals do that the windows terminal apparently cannot do, for example what if you want to re-size the window in both dimensions by dragging the border. The Windows terminal only allows you to change it's length.

Unix 风格的终端可以做很多 Windows 终端显然不能做的事情,例如,如果您想通过拖动边框在两个维度上重新调整窗口大小,该怎么办。Windows 终端只允许您更改它的长度。

Cut & Paste, on Linux or Unix, no problem - the selection box wraps around nicely so you can cut multi-line expressions. The Windows terminal (even in Quick-Edit mode) forces a bizarre rectangular selection box which is of no practical use - you have to re-format everything you copy in notepad!

剪切和粘贴,在 Linux 或 Unix 上,没问题 - 选择框很好地环绕,因此您可以剪切多行表达式。Windows 终端(即使在快速编辑模式下)强制使用一个奇怪的矩形选择框,它没有实际用途 - 您必须重新格式化在记事本中复制的所有内容!

What about the fact that any time I go into 'edit' mode it blocks the application - I'm sure there are people who want to be able to cut & paste without stopping the business-critical server.

每当我进入“编辑”模式时,它都会阻止应用程序这一事实呢?我相信有些人希望能够在不停止关键业务服务器的情况下进行剪切和粘贴。

I'm sure we can think of more faults if we put our minds to it - but lets not grumble.. what can we do to make this better?

我敢肯定,如果我们全神贯注,我们会想到更多的错误——但不要抱怨……我们能做些什么来让它变得更好?

Update: Just to clarify, I'm not looking to replace cmd.exe - Powershell & CygWin both provide better alternatives. I'm trying to replace the console application, the GUI that surrounds all text-applications in Windows.

更新:澄清一下,我不打算替换 cmd.exe - Powershell 和 CygWin 都提供了更好的替代方案。我正在尝试替换控制台应用程序,即围绕 Windows 中所有文本应用程序的 GUI。

回答by Lucas Jones

I personally use Console2with the Bash shipped with MYSYS-Git.

我个人将Console2MYSYS-Git附带的 Bash 一起使用。

You can also use PuTTY and SSH to a real linux box ;-)

您还可以使用 PuTTY 和 SSH 连接到真正的 linux 机器 ;-)

回答by Noldorin

Use Console 2, perhaps? It's really quite stable now, and allows you to switch between cmd/PowerShell/cygwin/any other shell very easily. If we're honest about it, it's not likely Microsoft are going to improve the native Win32 console any time soon.

也许使用Console 2?它现在非常稳定,并且允许您非常轻松地在 cmd/PowerShell/cygwin/任何其他 shell 之间切换。老实说,微软不太可能在短期内改进原生 Win32 控制台。

回答by falstro

The only 'solution' that I have found to this problem is to install Cygwin/X and use XTerm instead. I use that every day at work.

我发现此问题的唯一“解决方案”是安装 Cygwin/X 并改用 XTerm。我每天都在工作中使用它。

回答by Colonel Panic

There are two things you can change independently—your terminal emulator and your shell.

您可以独立更改两件事——终端模拟器和 shell。

Use a better terminal emulator

使用更好的终端模拟器

This will allow you to select text normally (instead of stupid rectangles). I favour Console2, which is fast, lightweight and reliable http://sourceforge.net/projects/console/

这将允许您正常选择文本(而不是愚蠢的矩形)。我喜欢 Console2,它快速、轻量且可靠http://sourceforge.net/projects/console/

There's also ConEmu https://code.google.com/p/conemu-maximus5/.

还有 ConEmu https://code.google.com/p/conemu-maximus5/

There's also Mintty https://code.google.com/p/mintty/(same terminal emulator that Putty uses). Mintty can't run interactive apps like nanoor vi. Mintty can't run cmdeither, only Bash.

还有 Mintty https://code.google.com/p/mintty/(与 Putty 使用的终端模拟器相同)。Mintty 无法运行交互式应用程序,例如nanovi。Mintty 也不能运行cmd,只能运行Bash。

Whatever you choose, it's useful to add 'open console here' items to Windows Explorer context menu. Instructions at https://stackoverflow.com/a/17663556/284795

无论您选择什么,将“在此处打开控制台”项添加到 Windows 资源管理器上下文菜单都很有用。https://stackoverflow.com/a/17663556/284795 上的说明

Use a better shell

使用更好的外壳

Clink

碰杯

Clink improves cmd, adding session history, and Bash-style autocomplete. https://code.google.com/p/clink/

Clink 改进了cmd,添加了会话历史记录和 Bash 风格的自动完成。 https://code.google.com/p/clink/

Bash

重击

The most reliable distribution of Bash for Windows is with MSysGit. It's very easy to install, and you get a free Git https://code.google.com/p/msysgit/

Windows 版 Bash 最可靠的发行版是 MSysGit。安装非常简单,你可以得到一个免费的 Git https://code.google.com/p/msysgit/

It's worthwhile at this point to explain the difference between MSys and Cygwin. MSys is a collection of apps painstakingly ported to the native win32 API, whereas Cygwin is an emulation layer that can run arbitrary Linux apps.

在这一点上解释 MSys 和 Cygwin 之间的区别是值得的。MSys 是一组精心移植到本机 win32 API 的应用程序,而 Cygwin 是一个可以运行任意 Linux 应用程序的仿真层。

In my experience MSys is more comfortable, it interoperates better with Windows (in particular how it handles paths). Though Cygwin has more apps, and more recent.

根据我的经验,MSys 更舒适,它与 Windows 的互操作性更好(特别是它处理路径的方式)。虽然 Cygwin 有更多的应用程序,而且是最新的。

回答by Colonel Panic

I found iPythonin its -s mode to be as close as I can get. It also doubles as a python interactive shell.

我发现iPython在它的 -s 模式下尽可能接近。它还兼作 Python 交互式 shell。

回答by William T Wild

One of the first things I do to all my Windows machines is install Cygwin

我对所有 Windows 机器做的第一件事就是安装 Cygwin

There are some extensions for Cygwin too , like ssh and such.

Cygwin 也有一些扩展,比如 ssh 等。

回答by Bill K

Not a direct answer, but since you will occasionally HAVE to work in a windows CMD window there are 2 settings that are absolutely necessary to make it tollerable.

不是直接的答案,但由于您偶尔必须在 Windows CMD 窗口中工作,因此有 2 个设置是绝对必要的,以使其可以接受。

One of the very first things I do when I get on a new computer is set the screen buffer size to 9999(height), 300(or sow width). This allows you to scroll left and right to your hearts delight, and gives you a significant buffer for examining logs. Don't set the window size, it's virtually useless.

当我使用新计算机时,我做的第一件事就是将屏幕缓冲区大小设置为 9999(高度)、300(或母猪宽度)。这允许您向左和向右滚动以满足您的喜好,并为您检查日志提供重要的缓冲区。不要设置窗口大小,它几乎没用。

the other thing I do is check the "QuickEdit" mode, this makes copy/past much easier, and you can quickly pause a scrolling screen by clicking/dragging in it(to begin a selection).

我做的另一件事是检查“快速编辑”模式,这使得复制/过去更容易,并且您可以通过单击/拖动滚动屏幕(开始选择)来快速暂停滚动屏幕。

This isn't exactly a solution to the problem, just related advise that might be useful to solve the specific problem he mentioned in a different way (And a very useful habit!).

这并不完全是问题的解决方案,只是相关的建议,可能有助于以不同的方式解决他提到的特定问题(而且是一个非常有用的习惯!)。

回答by Steve

I use JTerm desktopconsole on Windows. It has Java implementations of all major Linux / Unix commands, such us ls, grep, find, cd, cp, mv etc. It has some limitations, but overall it works will.

我在 Windows 上使用JTerm 桌面控制台。它具有所有主要 Linux / Unix 命令的 Java 实现,例如我们 ls、grep、find、cd、cp、mv 等。它有一些限制,但总体而言它可以工作。

回答by Akash

IF YOU WANT A CYGWIN ALTERNATIVE

如果您想要 CYGWIN 替代品

npm install -g cash-global

npm install -g cash-global

There is a well written blogabout The Cash Shell.

有一个写得很好的博客关于The Cash Shell.

You can also check out the npmpackage here.

您也可以在此处查看npm包裹。

Hope this helps.

希望这可以帮助。

回答by casualcoder

I have not tried KDE on WIndows, but it is allegedly now available in the latest release at writing.

我没有在 WINdows 上尝试过KDE,但据称它现在可以在写作的最新版本中使用。