Getting started with the fish shell in Linux systems

Source: Internet
Author: User
Tags config advantage

Installation and Configuration

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

This is what Ubuntu says:

The code is as follows:

sudo apt-get install fish

Get into fish from bash and just type in fish.

Install the first step is to modify the OS default shell:

The code is as follows:

Chsh-s/usr/bin/fish

Then it can be used directly, it is so simple. You don't have to face the zsh configuration file, and you don't need to GitHub clone a "Oh my zsh".

Of course, if you really want to configure, the Enter Fish_config command launches the Web admin interface.

What? The force is too low to be manually configured. OK, ~/.config/fish/config.fish This is fish's profile, similar to Bash's. bashrc.

I like to configure three things:

1. Greeting (Configuration Config.fish):

The code is as follows:

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

2. Command prompt (in the Web interface configuration, after completion will generate ~/.config/fish/functions/fish_prompt.fish):

3. Set shortcut keys to accept recommendations (third advantage):

Modify Fish_prompt.fish, add 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 characters

Integrated Find command, recursive search artifact.

Smart Advice

When you press a few letters, fish will have smart suggestions, press the right arrow to accept the suggestion.

tab complement

If the complement is more than 1, all are listed for selection.

Variable

Fish is assigned to variables by using set instead of "=".

Adding a directory to path also uses set (Configuration config.sh):

The code is as follows:

Set PATH $PATH/home/mountain/shell

Exports

Fish has no export order and needs to be replaced with set-x. If you need to erase a variable, execute set-e.

List

Some variables have multiple values, such as $path,fish, which assembles all the values into a list that can be iterated or accessed by subscript.

Command substitution

The usage is simple, put the order in parentheses.

Grammar sugar

Fish's commonly used keywords (if, switch, function, and so on) are much higher and more useful than bash, but given that the company's production environment is unlikely to install fish, causing the script to be unable to migrate, this part can only be reluctantly discarded.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.