Get the App
SLTechnology News&Howtos  ›  Servers  › 

Introduction to the method of using Fish Shell in Linux system

Shulou Source: shulou.com Published: 2022-06-01 15:19:16 09月15日 Update

The main content of this article is "introduction to the method of using Fish Shell in Linux system". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "introduction to the method of using Fish Shell in Linux system".

Installation and configuration

Linux and OS X can basically be installed through the source, it is not difficult to download the source code to compile.

This is what Ubuntu says:

The code is as follows:

Sudo apt-get install fish

Enter fish from bash and enter fish directly.

The first step to install is to modify the OS default shell:

The code is as follows:

Chsh-s / usr/bin/fish

Then you can use it directly. It's as simple as that. You don't have to face a sea of zsh configuration files, and you don't need to github clone a "Oh My Zsh".

Of course, if you really want to configure it, typing the fish_config command will launch the web management interface.

What? The force box is too low and must be configured manually. OK, ~ / .config / fish/config.fish this is the configuration file for fish, similar to bash's .bashrc.

I like to configure three things:

1. Greeting (configure config.fish):

The code is as follows:

Set fish_greeting 'Talk is cheap. Show me the code.'

two。 Command line prompt (configured in the web interface, ~ / .config/fish/functions/fish_prompt.fish will be generated after completion):

3. Set the shortcut key to accept the suggestion (the third advantage):

Modify fish_prompt.fish by adding a statement: bind\ ej accept-autosuggestion. Press alt and j at the same time to accept the proposal.

advantage

Syntax highlighting

Commands that do not exist are displayed in red.

Wildcard character

Integrated find command, recursive search artifact.

Intelligent advice

After pressing a few letters, fish will have a smart suggestion, press the right arrow to accept the suggestion.

Tab completion

If there are more than 1 completion item, all of them will be listed for selection.

Variable

Fish uses set instead of "=" to assign values to variables.

Adding a directory to PATH also uses set (configure config.sh):

The code is as follows:

Set PATH $PATH / home/mountain/shell

Exports

Fish does not have an export command, so you need to use set-x instead. If you need to erase the variable, execute set-e.

List

Some variables have multiple values, such as $PATH,fish, which assembles all values into a list that can be iterated or accessed through subscripts.

Command replacement

The usage is simple, just put the command in parentheses.

Grammatical sugar

The common keywords of fish (if, switch, function, etc.) are much more high-end and practical than bash, but considering that it is impossible to install fish in the company's production environment, so the script can not be ported, so I can only give up this part.

At this point, I believe you have a deeper understanding of "introduction to the method of using Fish Shell in Linux system". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Configuration commands suggestions methods codes variables systems that is utility advantages content files intelligence interface grammar learning input no deeper vast Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei MySQL Redmi vpn OPPO Reno