Catalog / Fish Shell Scripting Cheatsheet
Fish Shell Scripting Cheatsheet
A comprehensive guide to Fish shell scripting, covering syntax, commands, and best practices for efficient shell scripting.
Fish Shell Basics
Core Syntax
Variable Assignment |
|
Accessing Variables |
|
String Concatenation |
|
Command Substitution |
|
Comments |
|
Exit Status |
|
Control Flow
If Statement |
|
For Loop |
|
While Loop |
|
Switch Statement |
|
Functions
Function Definition |
|
Calling Functions |
|
Function Arguments |
|
Return Values |
Use |
Common Commands & Utilities
File and Directory Operations
Create Directory |
|
Remove Directory |
|
Create File |
|
Remove File |
|
Copy File |
|
Move/Rename File |
|
List Files |
|
Text Manipulation
Print to Console |
|
Grep (Search) |
|
Sed (Stream Editor) |
|
Awk (Pattern Scanning) |
|
String Length |
|
Process Management
Run Command in Background |
|
List Running Processes |
|
Kill Process |
|
Foreground Process |
|
Advanced Fish Scripting
Error Handling
Check Exit Status |
|
Try…Catch (Simulated) |
|
Using |
Forces execution of external command instead of shell function with same name. Useful in scripts. |
Signals
Trapping Signals |
Fish does not directly support |
Input and Output Redirection
Redirect Output to File |
|
Redirect Input from File |
|
Pipe Output |
|
Redirect Standard Error |
|
Working with Lists
Creating a List |
|
Accessing List Elements |
|
List Length |
|
Iterating Over a List |
|
Configuration and Customization
Configuration Files
Global Configuration |
|
Functions Directory |
|
Autocompletions Directory |
|
Custom Functions
Creating a Function |
|
Making it Persistent |
Save the function in |
Aliases
Creating Aliases (Abbreviations) |
|
Making Aliases Persistent |
Add |
Autocompletions
Creating Autocompletions |
Use |
Custom Completion Files |
Store completion definitions in |