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 install and use fish shell under Linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article will explain in detail how to install and use fish shell under Linux. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

Fish is a very user-friendly and feature-rich shell, but it is not included in the default repository for most Linux distributions. It can only be found in official repositories in a few Linux distributions.

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.

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

Sudo-u [user] chsh-s / usr/bin/fish

The OS X system needs to confirm that the / etc/shells file contains / usr/local/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:

Greeting (configure config.fish):

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

X OS system vs code Command Line tool (configure config.fish)

Function code set location "$PWD/$argv" open-n-b "com.microsoft.VSCode"-- args $locationend

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

Selection_001.png

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.

Selection_001.png

Selection_002.png

Wildcard character

Integrated find command, recursive search artifact.

Selection_003.png

Intelligent advice

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

Selection_004.png

Tab completion

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

Selection_005.png

Variable

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

Selection_006.png

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

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.

Img

Selection_007.png

Selection_008.png

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.

Selection_001.png

Command replacement

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

Selection_002.png

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.

This is the end of the article on "how to install and use fish shell under Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

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

Development

Wechat

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

12
Report