From 73f97bac4f1fe511917e02b8622727c08fc620c4 Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 31 Mar 2020 08:23:39 +0800 Subject: [PATCH] translated --- ...309 Fish - A Friendly Interactive Shell.md | 194 ------------------ ...309 Fish - A Friendly Interactive Shell.md | 194 ++++++++++++++++++ 2 files changed, 194 insertions(+), 194 deletions(-) delete mode 100644 sources/tech/20200309 Fish - A Friendly Interactive Shell.md create mode 100644 translated/tech/20200309 Fish - A Friendly Interactive Shell.md diff --git a/sources/tech/20200309 Fish - A Friendly Interactive Shell.md b/sources/tech/20200309 Fish - A Friendly Interactive Shell.md deleted file mode 100644 index b091fea171..0000000000 --- a/sources/tech/20200309 Fish - A Friendly Interactive Shell.md +++ /dev/null @@ -1,194 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Fish – A Friendly Interactive Shell) -[#]: via: (https://fedoramagazine.org/fish-a-friendly-interactive-shell/) -[#]: author: (Michal Konečný https://fedoramagazine.org/author/zlopez/) - -Fish – A Friendly Interactive Shell -====== - -![Fish — A Friendly Interactive Shell][1] - -Are you looking for an alternative to bash? Are you looking for something more user-friendly? Then look no further because you just found the golden fish! - -Fish (friendly interactive shell) is a smart and user-friendly command line shell that works on Linux, MacOS, and other operating systems. Use it for everyday work in your terminal and for scripting. Scripts written in fish are less cryptic than their equivalent bash versions. - -### Fish’s user-friendly features - - * **Suggestions** -Fish will suggest commands that you have written before. This boosts productivity when typing same commands often. - * **Sane scripting** -Fish avoids using cryptic characters. This provides a clearer and friendlier syntax. - * **Completion based on man pages** -Fish will autocomplete parameters based on the the command’s man page. - * **Syntax highlighting** -Fish will highlight command syntax to make it visually friendly. - - - -### Installation - -#### Fedora Workstation - -Use the _dnf_ command to install fish: - -``` -$ sudo dnf install fish -``` - -Make fish your default shell by installing the _util-linux-user_ package and then running the _chsh_ (change shell) command with the appropriate parameters: - -``` -$ sudo dnf install util-linux-user -$ chsh -s /usr/bin/fish -``` - -You will need to log out and back in for this change to take effect. - -#### Fedora Silverblue - -Because this is not GUI application, you will need to layer it using _rpm-ostree_. Use the following command to install fish on Fedora Silverblue: - -``` -$ rpm-ostree install fish -``` - -On Fedora Silverblue you will need to reboot your PC to switch to the new ostree image. - -If you want to make fish your main shell on Fedora Silverblue, the easiest way is to update the _/etc/passwd_ file. Find your user and change _/bin/bash_ to _/usr/bin/fish_. - -You will need [root privileges][2] to edit the _/etc/passwd_ file. Also you will need to log out and back in for this change to take effect. - -### Configuration - -The per-user configuration file for fish is _~/.config/fish/config.fish_. To make configuration changes for all users, edit _/etc/fish/config.fish_ instead. - -The per-user configuration file must be created manually. The installation scripts will not create _~/.config/fish/config.fish_. - -Here are a couple configuration examples shown alongside their bash equivalents to get you started: - -#### Creating aliases - - * _~/.bashrc_: alias ll='ls -lh' - * _~/.config/fish/config.fish_: alias ll='ls -lh' - - - -#### Setting environment variables - - * _~/.bashrc_: export PATH=$PATH:~/bin - * _~/.config/fish/config.fish_: set -gx PATH $PATH ~/bin - - - -### Working with fish - -When fish is configured as your default shell, the command prompt will look similar to what is shown in the below image. If you haven’t configured fish to be your default shell, just run the _fish_ command to start it in your current terminal session. - -![][3] - -As you start typing commands, you will notice the syntax highlighting: - -![][4] - -Cool, isn’t it? 🙂 - -You will also see commands being suggested as you type. For example, start typing the previous command a second time: - -![][5] - -Notice the gray text that appears as you type. The gray text is fish suggesting the command you wrote before. To autocomplete it, just press **CTRL+F**. - -Get argument suggestions based on the preceding command’s man page by typing a dash (**–**) and then the **TAB** key: - -![][6] - -If you press **TAB** once, it will show you the first few suggestions (or every suggestion, if there are only a few arguments available). If you press **TAB** a second time, it will show you all suggestions. If you press **TAB** three times consecutively, it will switch to interactive mode and you can select an argument using the arrow keys. - -Otherwise, fish works similar to most other shells. The remaining differences are well documented. So it shouldn’t be difficult to find other features that you may be interested in. - -### Make fish even more powerful - -Make the fish even more powerful with [powerline][7]. Powerline adds command execution time, colored git status, current git branch and much more to fish’s interface. - -Before installing powerline for fish, you must install [Oh My Fish][8]. Oh My Fish extends fish’s core infrastructure to enable the installation of additional plugins. The easiest way to install Oh My Fish is to use the _curl_ command: - -``` -> curl -L https://get.oh-my.fish | fish -``` - -If you don’t want to pipe the installation commands directly to _curl_, see the installation section of Oh My Fish’s [README][9] for alternative installation methods. - -Fish’s powerline plugin is [bobthefish][7]. Bobthefish requires the _powerline-fonts_ package. - -**On Fedora Workstation**: - -``` -> sudo dnf install powerline-fonts -``` - -**On Fedora Silverblue**: - -``` -> rpm-ostree install powerline-fonts -``` - -On Fedora Silverblue you will have to reboot to complete the installation of the fonts. - -After you have installed the _powerline-fonts_ package, install _bobthefish_: - -``` -> omf install bobthefish -``` - -Now you can experience the full awesomeness of fish with powerline: - -![][10] - -### Additional resources - -Check out these web pages to learn even more about fish: - - * [Official page][11] - * [Documentation][12] - * [Tutorial][13] - * [FAQ][14] - * [Web playground][15] - * [Mailing lists][16] - * [GitHub][17] - - - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/fish-a-friendly-interactive-shell/ - -作者:[Michal Konečný][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/author/zlopez/ -[b]: https://github.com/lujun9972 -[1]: https://fedoramagazine.org/wp-content/uploads/2020/03/fish-816x345.jpg -[2]: https://fedoramagazine.org/howto-use-sudo/ -[3]: https://fedoramagazine.org/wp-content/uploads/2020/03/Screenshot-from-2020-03-03-14-00-35.png -[4]: https://fedoramagazine.org/wp-content/uploads/2020/03/Screenshot-from-2020-03-03-14-19-24.png -[5]: https://fedoramagazine.org/wp-content/uploads/2020/03/Screenshot-from-2020-03-03-14-25-31.png -[6]: https://fedoramagazine.org/wp-content/uploads/2020/03/Screenshot-from-2020-03-03-14-58-07.png -[7]: https://github.com/oh-my-fish/theme-bobthefish -[8]: https://github.com/oh-my-fish/oh-my-fish -[9]: https://github.com/oh-my-fish/oh-my-fish/blob/master/README.md#installation -[10]: https://fedoramagazine.org/wp-content/uploads/2020/03/Screenshot-from-2020-03-03-15-38-07.png -[11]: https://fishshell.com/ -[12]: https://fishshell.com/docs/current/index.html -[13]: https://fishshell.com/docs/current/tutorial.html -[14]: https://fishshell.com/docs/current/faq.html -[15]: https://rootnroll.com/d/fish-shell/ -[16]: https://sourceforge.net/projects/fish/lists/fish-users -[17]: https://github.com/fish-shell/fish-shell/ diff --git a/translated/tech/20200309 Fish - A Friendly Interactive Shell.md b/translated/tech/20200309 Fish - A Friendly Interactive Shell.md new file mode 100644 index 0000000000..8f786287ad --- /dev/null +++ b/translated/tech/20200309 Fish - A Friendly Interactive Shell.md @@ -0,0 +1,194 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Fish – A Friendly Interactive Shell) +[#]: via: (https://fedoramagazine.org/fish-a-friendly-interactive-shell/) +[#]: author: (Michal Konečný https://fedoramagazine.org/author/zlopez/) + +Fish – 一个友好的交互式 Shell +====== + +![Fish — A Friendly Interactive Shell][1] + +你是否正在寻找 bash 的替代品?你是否在寻找更人性化的东西?再往前看看,因为你刚发现了 fish! + +Fish(友好的交互式 shell)是一个智能且用户友好的命令行 shell,可在 Linux、MacOS 和其他操作系统上运行。将其用于终端的日常工作和脚本编写。用 fish 编写的脚本比相同的 bash 版本具有更少的神秘性。 + +### Fish 的用户友好功能 + + * **建议** +Fish 会建议你之前写过的命令。当经常输入相同命令时,这可以提高生产率。 + * **健全的脚本** +Fish 避免使用隐秘字符。这提供了更清晰和更友好的语法。 + * **基于手册页的补全** +Fish 会根据命令的手册页自动补全参数。 + * **语法高亮** +Fish 会高亮显示命令语法以使其在视觉上友好。 + + + +### 安装 + +#### Fedora 工作站 + +使用 _dnf_ 命令安装 fish: + +``` +$ sudo dnf install fish +``` + +安装 _util-linux-user_ 包,然后使用适当的参数运行 _chsh_(更改 shell 程序)命令,将 fish 设置为默认 shell 程序: + +``` +$ sudo dnf install util-linux-user +$ chsh -s /usr/bin/fish +``` + +你需要注销然后重新登录,更改才能生效。 + +#### Fedora Silverblue + +由于它不是 GUI 应用,因此你需要使用 _rpm-ostree_ 安装。使用以下命令在 Fedora Silverblue 上安装 fish: + +``` +$ rpm-ostree install fish +``` + +在 Fedora Silverblue 上,你需要重启 PC 才能切换到新的 ostree 镜像。 + +如果你想在 Fedora Silverblue 用 fish 作为主要 shell,最简单的方法是更新 _/etc/passwd_ 文件。找到你的用户,并将 _/bin/bash_ 更改为 _/usr/bin/fish_。 + +、你需要 [root 权限][2]来编辑 _/etc/passwd_ 文件。另外,你需要注销并重新登录才能使更改生效。 + +### 配置 + +fish 的用户配置文件在 _~/.config/fish/config.fish_。要更改所有用户的配置,请编辑 _/etc/fish/config.fish_。 + +每个用户的配置文件必须手动创建。安装脚本不会创建 _〜/ .config / fish / config.fish_。 + +以下是几个配置示例以及它们的 bash 等效项,以帮助你入门: + +#### 创建别名 + + * _~/.bashrc_: alias ll='ls -lh' + * _~/.config/fish/config.fish_: alias ll='ls -lh' + + + +#### 设置环境变量 + + * _~/.bashrc_: export PATH=$PATH:~/bin + * _~/.config/fish/config.fish_: set -gx PATH $PATH ~/bin + + + +### 使用 fish 工作 + +将 fish 配置为默认 shell 程序后,命令提示符将类似于下图所示。如果尚未将 fish 配置为默认 shell,只需运行 _fish_ 命令以在当前终端会话中启动。 + +![][3] + +在你开始输入命令时,你会注意到语法高亮显示: + +![][4] + +很酷,不是吗?🙂 + +你还将在输入时看到建议的命令。例如,再次开始输入上一个命令: + +![][5] + +注意输入时出现的灰色文本。灰色文本显示建议之前编写的命令。要自动补全,只需按 **CTRL+F**。 + +通过输入连接号(**–**)然后使用 **TAB** 键,它会根据前面命令的手册页获取参数建议: + +![][6] + +如果你按一次 **TAB**,它将显示前几个建议(或所有建议,如果只有少量参数可用)。如果再次按 **TAB**,它将显示所有建议。如果连续三次按 **TAB**,它将切换到交互模式,你可以使用箭头键选择一个参数。 + +除此之外,fish 的工作与大多数其他 shell 相似。其他差异已经写在文档中。因此,找到你可能感兴趣的其他功能应该不难。 + +### 让 fish 变得更强大 + +使用 [powerline][7] 使 fish 变得更强大。Powerline 将命令执行时间、彩色化 git 状态、当前 git 分支等添加到了 fish 的界面中。 + +在安装 powerline 之前,你必须先安装 [Oh My Fish][8]。Oh My Fish 扩展了 fish 的核心基础架构,以支持安装其他插件。安装 Oh My Fish 的最简单方法是使用 _curl_ 命令: + +``` +> curl -L https://get.oh-my.fish | fish +``` + +如果你不想直接将安装命令管道传给 _fish_,请参见 Oh My Fish 的 [README][9] 的安装部分,以了解其他安装方法。 + +Fish 的 powerline 插件是 [bobthefish][7]。Bobthefish 需要 _powerline-fonts_ 包。 + +**在Fedora工作站上**: + +``` +> sudo dnf install powerline-fonts +``` + +**在 Fedora Silverblue 上**: + +``` +> rpm-ostree install powerline-fonts +``` + +在 Fedora Silverblue 上,你必须重启以完成字体的安装。 + +安装 _powerline-fonts_ 之后,安装 _bobthefish_: + +``` +> omf install bobthefish +``` + +现在你可以通过 powerline 体验 fish 的全部奇妙之处: + +![][10] + +### 额外的资源 + +查看这些网页,了解更多 fish 内容: + + * [官网][11] + * [文档][12] + * [教程][13] + * [常见问题][14] + * [在线体验][15] + * [邮件列表][16] + * [GitHub][17] + + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/fish-a-friendly-interactive-shell/ + +作者:[Michal Konečný][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/zlopez/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/03/fish-816x345.jpg +[2]: https://fedoramagazine.org/howto-use-sudo/ +[3]: https://fedoramagazine.org/wp-content/uploads/2020/03/Screenshot-from-2020-03-03-14-00-35.png +[4]: https://fedoramagazine.org/wp-content/uploads/2020/03/Screenshot-from-2020-03-03-14-19-24.png +[5]: https://fedoramagazine.org/wp-content/uploads/2020/03/Screenshot-from-2020-03-03-14-25-31.png +[6]: https://fedoramagazine.org/wp-content/uploads/2020/03/Screenshot-from-2020-03-03-14-58-07.png +[7]: https://github.com/oh-my-fish/theme-bobthefish +[8]: https://github.com/oh-my-fish/oh-my-fish +[9]: https://github.com/oh-my-fish/oh-my-fish/blob/master/README.md#installation +[10]: https://fedoramagazine.org/wp-content/uploads/2020/03/Screenshot-from-2020-03-03-15-38-07.png +[11]: https://fishshell.com/ +[12]: https://fishshell.com/docs/current/index.html +[13]: https://fishshell.com/docs/current/tutorial.html +[14]: https://fishshell.com/docs/current/faq.html +[15]: https://rootnroll.com/d/fish-shell/ +[16]: https://sourceforge.net/projects/fish/lists/fish-users +[17]: https://github.com/fish-shell/fish-shell/