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 the Linux fishshell command

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces the relevant knowledge of how to install and use the Linux fishshell command, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this article on how to install and use the Linux fishshell command. Let's take a look.

Fishshell is easier to use than bash. Shell

Installation method for installing # Ubuntu and Debian. The installation method of sudo apt-get install fish # Mac. Brew install fish startup and help because the syntax of Fish is very different from that of Bash, Bash scripts are generally incompatible. Therefore, it is recommended that you do not set Fish as the default Shell, but start it manually each time.

# after the installation is complete, you can start Fish. During the use of $fish #, you can enter the help command $help color display # invalid command is red $mkd # valid command is blue $mkdir # valid path will be underlined If there is no underscore, you will know that this path does not exist. $cat ~ / somefi automatic suggestion Fish will automatically give a suggestion behind the cursor to indicate possible options, the color is gray. If you take the suggestion, you can press → or Control + F. If only part of it is adopted, press Alt + →.

The $/ bin/hostname # command suggests $grep-- the ignore-case # parameter suggests $ls node_modules # path suggests automatic completion of the input command, Fish will automatically display the last history that matches. If there is no matching history, Fish guesses the possible results and automatically completes various inputs. For example, typing pyt and then pressing Tab will automatically complete the command to python.

Fish can also automatically complete Git branches.

Script syntax if statement if grep fish / etc/shells echo Found fish else if grep bash / etc/shells echo Found bash else echo Got nothing endswitch statement switch (uname) case Linux echo Hi Tux! Case Darwin echo Hi Hexley! Case FreeBSD NetBSD DragonFly echo Hi Beastie! Case'* 'echo Hi, stranger! The endwhile loop while true echo "Loop forever" endfor loop for file in *. Txt cp $file $file.bak end function Fish is used to encapsulate commands or give aliases to existing commands.

Function ll ls-lhG $argvend the above code defines a ll function. After the command line executes this function, you can replace ls-lhG with the ll command. Where the variable $argv represents the parameters of the function.

The code above function ls command ls-hG $argvend redefines the ls command. Note that command should be added before the ls in the function body, otherwise an error will be reported because of an infinite loop.

The prompt fish_prompt function defines the command line prompt (prompt).

After function fish_prompt set_color purple date "+% m/%d/%y" set_color FF0 echo (pwd)'> 'set_color normalend executes the above function, your command line prompt will look like this.

The configuration file for 02/06/13/home/tutorial > configuration Fish is ~ / .config / fish/config.fish, which is automatically loaded every time Fish starts. Fish also provides a Web interface to configure the file.

$fish_config # browser opens the Web interface to configure Running Commands: compatible with shell command execution methods such as bash

Getting Help: help/man cmd-> browser/terminal

Syntax Highlighting: check whether the command is correct in real time

Wildcards: supports acronym * recursive matching

Pipes and Redirections: use ^ to represent stderr

Autosuggestions: automatically recommended. You can use Ctrl-f /-> to complete.

Tab Completions: a more powerful tab completion

Variables: using set settin

Exit Status: use echo $status instead of $? Exports (Shell Variables)

Lists: all variables in fish are really lists

Command Substitutions: use (cmd) to execute commands instead of backquotes, $()

Combiners (And, Or, Not): does not support the use of coincidence to represent logical operations

Functions: use $argv instead of $1

Conditionals (If, Else, Switch) / Functions / Loops: a more humane way of writing

Prompt: function fish_prompt implementation

Startup (Where's .bashrc?): ~ / .config / fish/config.fish, better way is autoloading-function, universal-variables Autoloading Functions: ~ / .config/fish/functions/.

Universal Variables:a variable whose value is shared across all instances of fish

Set name 'czl' # set variable, replace name=czlecho $nameecho $status # exit status, replace $? env # environment variable set-x MyVariable SomeValue # replace exportset-e MyVariableset PATH $PATH / usr/local/bin # use lists record PATHset-U fish_user_paths / usr/local/bin $fish_user_paths # permanent touch "testing_" (date +% s) ".txt" # command subtitution, replace `date +% s`cp file.txt file.txt.bak; and echo' back success' Or echo 'back fail' # combinerfunctions # lists the functions defined under fish on "how to install and use Linux fishshell commands". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to install and use Linux fishshell commands". If you want to learn more, you are welcome to follow the industry information channel.

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: 259

*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