Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Fish in linux

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use Fish in linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Fish (friendly Interactive shell) is an intelligent and user-friendly command-line shell that runs on Linux, MacOS, and other operating systems. It can be used for the daily work of the terminal and for scripting. Scripts written in fish are less mysterious than the same version of bash.

User-friendly features of Fish

Suggestion: Fish will prompt you for previously written commands. This increases productivity when you often enter the same command.

Sound scripting ability: Fish avoids using secret characters. This provides a clearer and friendlier syntax.

Man page-based completion: Fish automatically completes the parameters according to the man page of the command.

Syntax highlighting: Fish highlights the command syntax to make it visually friendly.

Install Fedora workstation

Use the dnf command to install fish:

$sudo dnf install fish

Install the util-linux-user package, and then run the chsh (change shell Program) command with the appropriate parameters to set fish as the default shell program:

$sudo dnf install util-linux-user$ chsh-s / usr/bin/fish

You need to log out and log back in for the changes to take effect.

Fedora Silverblue

Since it is not a GUI application, you need to use rpm-ostree to add it to the layer. Install fish on Fedora Silverblue using the following command:

$rpm-ostree install fish

On Fedora Silverblue, you need to restart PC to switch to the new ostree image.

If you want to use fish as the primary shell in Fedora Silverblue, the easiest way is to update the / etc/passwd file. Find your user and change / bin/bash to / usr/bin/fish.

You need root permission to edit the / etc/passwd file. In addition, you need to log out and log back in for the changes to take effect.

Configuration

The user profile for fish is in ~ / .config / fish/config.fish. To change the configuration for all users, edit / etc/fish/config.fish.

The user profile must be created manually. The installation script does not create ~ / .config / fish/config.fish.

Here are two configuration examples and their bash equivalents to help you get started:

Create an alias

~ / .bashrc:alias ll='ls-lh'

~ / .config/fish/config.fish: alias ll='ls-lh'

Set environment variabl

~ / .bashrc:export PATH=$PATH:~/bin

~ / .config/fish/config.fish:set-gx PATH $PATH ~ / bin

Working with fish

When fish is configured as the default shell program, the command prompt will look similar to the following figure. If fish has not been configured as the default shell, simply run the fish command to start in the current terminal session.

When you start typing commands, you will notice that the syntax is highlighted:

Cool, isn't it? ?

You will also see the recommended commands as you type. For example, start entering the previous command again:

Notice the gray text that appears as you type. The gray text shows the command written before the suggestion. To complete automatically, just press CTRL+F.

By entering the connection number (-) and then using the TAB key, it gets parameter recommendations based on the man page of the previous command:

If you press TAB once, it will display the first few suggestions (or all suggestions, if only a few parameters are available). If you press TAB again, it will display all suggestions. If you press TAB three times in a row, it will switch to interactive mode and you can use the arrow keys to select a parameter.

In addition, fish works like most other shell. Other differences have been written in the document. Therefore, it should not be difficult to find other features that may interest you.

Make fish stronger

Use powerline to make fish more powerful. Powerline can add command execution time, colorized git status, current git branch, and so on, to the interface of fish.

Before you can install powerline, you must install Oh My Fish. Oh My Fish extends the core infrastructure of fish to support the installation of other plug-ins. The easiest way to install Oh My Fish is to use the curl command:

> curl-L https://get.oh-my.fish | fish

If you do not want to pipe the installation commands directly to fish, see the README installation section of Oh My Fish for other installation methods.

The powerline plug-in for Fish is bobthefish. Bobthefish requires a powerline-fonts package.

On the Fedora workstation:

> sudo dnf install powerline-fonts

On Fedora Silverblue:

> rpm-ostree install powerline-fonts

On Fedora Silverblue, you must restart to complete the font installation.

After installing powerline-fonts, install bobthefish:

> omf install bobthefish

Now you can experience all the wonders of fish through powerline:

Thank you for reading this article carefully. I hope the article "how to use Fish in linux" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report