Nushell： 一个让你更清楚地了解错误信息的跨平台 Shell
Nushell shell
![](/data/attachment/album/202204/30/181450b5r4m5jb77llrfru.jpg)



> 
> Nushell 是一个独特的 Shell，它提供易于阅读的错误信息，以及跨平台支持。在这里可以了解到更多关于它的信息。
> 
> 
> 


即使你对使用终端不感兴趣，Linux 终端也常常使一些繁重的工作变得更加轻松，以及可以让你修复一些东西。因此，可以说，如果你知道自己在做什么，Linux 终端是相当强大的。


这也是事实！但是当你看到一些错误消息就表明出现问题了。如果你没有足够的使用经验，可能不知道如何解决它。


虽然这些错误信息试图向你传达该问题的最佳含义，但不是每个用户都能轻易理解该如何修复。对于初学者来说，这通常需要进行一些研究。但是，如果错误能更清晰一些，用户就能更快地解决它。


不仅仅限于错误信息，例如，你在终端浏览文件时看到的输出结构，也不是最漂亮的。


![Terminal listing several files](/data/attachment/album/202204/30/181456vd8nvatut5p844jd.png)


**你明白我的意思吗？** 当然，当你有更多不同类型的文件时，这可能变得更加复杂。而且，你无法从基本的 `ls` 命令的输出中了解到文件的权限、组等。


这就是 Nushell 试图解决的问题。


### Nushell：一个默认提供用户友好输出的 Shell


![Nushell example screenshot](/data/attachment/album/202204/30/181456ri27yfx2gkhibypf.jpg)


Nushell 也被称为 Nu，它的理念和灵感来自于 [PowerShell](https://itsfoss.com/microsoft-open-sources-powershell/)、函数式编程语言和现代 [CLI](https://itsfoss.com/gui-cli-tui/) 工具等项目。


让我给你举个例子，想象一下你只想让你的输出列出你的主目录内类型为文件的项目，包括隐藏文件。那么，要实现这一点，只要输入下面的命令就可以了：



```
ls -a | where type == 'file'

```

![Listing only files with Nushell](/data/attachment/album/202204/30/181456fruklqauk1aaaacc.png)


观察一下，它的语法是多么清晰和简单。现在想象一下，用 Nushell 查找进程和名称 ID、它的状态，以及 CPU 或内存消耗是多么容易。**这是它魔法的一部分！**


它会尽力以专门组织的方式为你输入的命令提供适合用户的输出。


### Nushell 的特点


![Error messages in Nu, one of its primary highlights](/data/attachment/album/202204/30/181456bvszq4v10e1yhjns.png)


根据现有的官方信息，它的一些最受欢迎的功能包括：


* **任何操作系统都通过管道进行控制。** Nu 可以在 Linux、macOS 和 Windows 上工作。换句话说，作为一个灵活的跨平台 shell，具有现代感。
* **一切都是数据。** Nu 管道使用结构化数据，所以你可以安全地选择、过滤和排序，每次都是同样的方式。
* **强大的插件。** 使用强大的插件系统，很容易扩展 Nu 的功能。
* **易于阅读的错误信息。** Nu 操作的是类型化的数据，所以它可以捕捉到其他 shell 所没有的错误。当错误发生时，Nu 会告诉你确切的位置和原因。
* 清晰的 IDE 支持。


你可以看看它的 [官方文档](https://www.nushell.sh/book/)，以全面了解它的功能和用法。


### 在你的系统中安装 Nushell


不幸的是，如果你是一个像我一样的 Ubuntu 用户，你将找不到安装 Nushell 的 APT 仓库。但是，你可以按照它在 [GitHub](https://github.com/nushell/nushell) 上的说明，通过安装所需的依赖项来构建它。


幸运的是，有一种方法可以在任何发行版上安装它，即使用 Homebrew。到它的官方网站去了解更多的安装选项。



> 
> **[Nushell](https://www.nushell.sh/)**
> 
> 
> 


你可以参考我们关于 [在 Linux 上安装和使用 Homebrew 包管理器](https://itsfoss.com/homebrew-linux/) 的教程。当你在 Linux 上成功设置了它，你需要输入以下命令来安装 Nushell：



```
brew install nushell

```

![Installing nushell with Homebrew](/data/attachment/album/202204/30/181457fqq3ggv9vsgqq3b4.png)


当这个过程完成后，只要输入 `nu` 就可以启动 Nushell shell。**这就完成了！**



> 
> 如果你想把 Nushell 设置为你的默认 shell，你可以用命令 `chsh` 来做，但是记住，它仍然在开发阶段，这就是为什么我们不推荐它用于日常使用。
> 
> 
> 


然而，在你决定尝试之前，你可以在其网站或 [GitHub 页面](https://github.com/nushell/nushell) 上了解关于它的更多信息。


你对这个有趣的 shell 什么看法？请在下面的评论中告诉我你的想法。


*题图由 [donations welcome](https://pixabay.com/zh/users/stux-12364/?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=2475272) 在 [Pixabay](https://pixabay.com/zh/?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=2475272) 上发布* 




---


via: <https://itsfoss.com/nushell/>


作者：[Marco Carmona](https://itsfoss.com/author/marco/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
**Brief:** Nushell is a unique type of shell that provides easy-to-read error messages and offers cross-platform support. Find out more about it here.

Even if you are not interested in using the terminal, the Linux terminal often makes some of the heavy lifting more effortless and lets you fix stuff. So, is safe to say that the Linux terminal is pretty powerful if you know what you’re doing.

And that is true! But the problem appears when you get an error. If you don’t have enough experience using it, you won’t know how to solve it.

While the error messages try to convey the best meaning of the problem, not every user can easily decode the fix. It usually takes a bit of research for beginners. But, if the error can have more clarity, the user could be able to fix it sooner.

Not just limited to the error message, the structure of the output you get in your terminal to browse files, for example, is not the prettiest.

![terminal with several files](https://itsfoss.com/content/images/wordpress/2022/04/Terminal-with-several-files-800x477.png)

**Do you see what I mean?** Of course, this could become more complex when you have more files of distinct types. And, you get no idea about file permissions, groups, etc with the output you get with the basic ls command.

That’s where Nushell tries to solve the problem.

## Nushell: A Shell That Provides User-Friendly Output by Default

![nushell example](https://itsfoss.com/content/images/wordpress/2022/04/Nushell-example-800x475.jpg)

Nu, as it’s also called, it takes its philosophy and inspiration from projects like [PowerShell](https://itsfoss.com/microsoft-open-sources-powershell/), functional programming languages, and modern [CLI](https://itsfoss.com/gui-cli-tui/) tools.

Let me give you an example, imagine you want to list only the output with a type equal to the file inside your home directory, including the hidden files. Well, to achieve this it is as easy as just typing the following command:

`ls -a | where type == 'file'`


![listing only files with nushell](https://itsfoss.com/content/images/wordpress/2022/04/Listing-only-files-with-nushell-800x246.png)

Observe how clear and simple its syntax is; now imagine how easy it could be to find the process and name ID, its status, and CPU or memory consumed with the Nushell. **It’s part of its magic!**

It tries its best to provide user-friendly output for the commands you enter, organized in a specific structure.

## Features of Nushell

![error messages in nu](https://itsfoss.com/content/images/wordpress/2022/04/Error-messages-in-Nu-800x259.png)

As per the official information available, some of its most popular features include:

**Pipelines to control any OS.**Nu works on Linux, macOS, and Windows. In other words, being a flexible cross-platform shell with a modern feel.**Everything is data.**Nu pipelines use structured data, so you can safely select, filter, and sort the same way every time.**Powerful plugins.**It’s easy to extend Nu functionalities using a powerful plugin system.**Easy to read error messages.**Nu operates on typed data, so it catches bugs that other shells don’t. And when things break, Nu tells you exactly where and why.- Clean IDE support.

You can take a look at its [official documentation](https://www.nushell.sh/book/) for a thorough look at its features and usage.

## Installing Nushell in your system

Unfortunately, if you’re an Ubuntu user like me, you won’t find an apt repository to install Nushell. But, you can build it by installing the required dependencies, as per its instructions on [GitHub](https://github.com/nushell/nushell).

Fortunately, there is a way to install it on any distro, using **Homebrew**. Head to its official website to explore more installation options.

You can refer to our tutorial on [installing and using Homebrew Package Manager on Linux](https://itsfoss.com/homebrew-linux/). Once you successfully set it up on Linux, you need to type in the following command to install Nushell:

`brew install nushell`


![installing nushell with brew](https://itsfoss.com/content/images/wordpress/2022/04/Installing-nushell-with-brew-800x470.png)

Once the process is finished, just type `nu`

to start the Nushell shell. **That’s it!**

If you’d like to set Nushell as your default shell, you can do it with the command **chsh**, but remember, it is still in development, that’s why we do not recommend it for everyday use.

However, you can explore more about it on its website or the [GitHub page](https://github.com/nushell/nushell) before you decide to try it.

What do you think about this interesting shell? Let me know your thoughts in the comments down below.