How to use fish shell in Linux system

Time:2020-10-15

Installation and configuration
Linux and OS X can be installed through the source. If not, download the source code and compile it. It’s not difficult.
This is what Ubuntu says:

Copy code

The code is as follows:

sudo apt-get install fish

Enter fish from Bash and enter fish directly
The first step is to modify the OS default shell

Copy code

The code is as follows:

chsh -s /usr/bin/fish

And then you can use it directly. It’s that simple. You don’t have to face a huge number of configuration files for Zsh, and you don’t need to go to GitHub clone and “oh my Zsh”.

Of course, if you really want to configure it, type fish_ The config command starts the web management interface.

what? The force grid is too low. You have to configure it 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. Greetings (configuration config.fish ):

Copy code

The code is as follows:

set fish_greeting ‘Talk is cheap. Show me the code.’

2. Command line prompt (configure in the web interface, and ~ /. Config / fish / functions / fish will be generated_ prompt.fish ):
20151211113314900.png (817×776)

3. Set the shortcut key for accepting suggestions (the third advantage)

Modify fish_ prompt.fish , add a statement: bind / EJ accept autosuggestion. Pressing ALT and j at the same time will accept the suggestion.

advantage
Syntax highlighting
Commands that do not exist are displayed in red.
20151211113345561.png (193×24)

20151211113405279.png (202×19)

wildcard
Integration of find command, recursive search artifact.
20151211113425659.png (681×69)

Smart advice
When a few letters are pressed, fish will have intelligent suggestions, and pressing the right arrow will accept the suggestions.
20151211113441947.png (330×20)

Tab completion
If there is more than one completion, all items are listed for selection.
20151211113503576.png (262×39)

variable
Fish assigns values to variables through set instead of “=”.
20151211113550158.png (279×53)

To add a directory to the path, set is also used config.sh ):

Copy code

The code is as follows:

set PATH $PATH /home/mountain/shell

Exports
Fish has no export command and needs to be replaced by set – X. If you need to erase the variable, execute set – E.
20151211113628418.png (311×54)

20151211113659589.png (279×54)

list
Some variables have multiple values, such as $path. Fish assembles all the values into a list, which can be accessed iteratively or through subscripts.
20151211113718173.png (356×222)

Command replacement
The usage is very simple. Put the command in brackets.

Grammar sugar
The common keywords of fish (if, switch, function, etc.) are more advanced and practical than bash. However, considering that it is impossible to install fish in the company’s production environment, which leads to the script unable to be transplanted, we have to give up this part.
20151211113735887.png (271×54)

Recommended Today

Rust and python: why rust can replace Python

In this guide, we compare the rust and python programming languages. We will discuss the applicable use cases in each case, review the advantages and disadvantages of using rust and python, and explain why rust might replace python. I will introduce the following: What is rust? What is Python? When to use rust When to […]