Catalog / Fish Shell Cheatsheet
Fish Shell Cheatsheet
A comprehensive cheat sheet covering essential Fish shell commands, syntax, and configurations for improved productivity and customization.
Basics & Navigation
Shell Navigation
|
Change directory to |
|
Move one directory up. |
|
Return to the previous directory. |
|
Print the current working directory. |
|
List files and directories in the current directory. |
|
List files with detailed information (permissions, size, etc.). |
|
List all files, including hidden files. |
Basic Commands
|
Prints the specified text to the terminal. |
|
Prints the specified text with a trailing newline. |
|
Reads input from stdin and assigns it to |
|
Clears the terminal screen. |
|
Displays the command history. |
Keybindings
|
Move cursor to the beginning of the line. |
|
Move cursor to the end of the line. |
|
Jump to the previous word. |
|
Jump to the next word. |
|
Switch to the previous/next command in history. |
|
Switch to the previous/next arguments. |
|
Delete from cursor to the beginning of the line. |
|
Cancel the current command. |
Variables & Loops
Variable Management
|
Sets a variable named |
|
Sets a global variable accessible in all scopes. |
|
Sets a local variable, only accessible within the current scope. |
|
Removes the variable |
|
Prints the value of |
|
Prints a slice of the variable (characters 1 to 3). |
Loop Structures
|
Iterates over a list of items. |
|
Iterates over a sequence of numbers from 1 to 5. |
|
Executes a block of code as long as the condition is true. |
|
Exits the current loop. |
|
Skips the current iteration and continues with the next. |
Arithmetic Operations
|
Performs addition. |
|
Performs subtraction. |
|
Performs multiplication. |
|
Performs division. |
|
Calculates the modulo (remainder). |
|
Performs exponentiation. |
|
Increments a variable |
Conditionals & Strings
Conditional Statements
|
Executes a block of code if the condition is true. |
|
Executes a block of code if the previous |
|
Chains another condition to check if the initial |
|
Evaluates a condition; returns 0 if true, 1 if false. |
|
Logical AND operator for combining conditions. |
|
Logical OR operator for combining conditions. |
|
Logical NOT operator to negate a condition. |
String Manipulation
|
Returns the length of the string ‘text’. |
|
Extracts a substring of length 3 starting from index 2. |
|
Matches a string against a regular expression; returns the match or nothing. |
|
Replaces all occurrences of ‘old’ with ‘new’ in ‘string’. |
|
Joins items together with the specified separator. |
|
Splits a string into an array based on the separator. |
String Matching Patterns
|
Matches zero or one occurrences of |
|
Matches zero or more occurrences of |
|
Matches one or more occurrences of |
|
Matches exactly |
|
Matches between |
|
Matches either |
|
Matches any character that is not |
Functions & Events
Function Definition
|
Defines a new function named |
|
Defines a function accepting specific arguments. |
|
Adds a description to the function. |
|
Removes the function |
|
Exits the function, optionally returning a value. |
|
Array containing the arguments passed to the function. |
Event Handling
|
Emits an event named |
|
Defines a hook function that runs when |
|
Defines a hook function that runs when |
|
Defines a hook function that runs when the |
Process Communication
|
Redirects the output to a file, overwriting its contents. |
|
Appends the output to a file. |
|
Pipes the output to another command. |
|
Command substitution; replaces the command with its output. |
|
Process substitution; creates a temporary file with the output of the command. |
Abbreviations & Completions
Abbreviations
|
Adds an abbreviation; typing |
|
Removes the abbreviation |
|
Lists all defined abbreviations. |
Example:
|
Creates an abbreviation for |
Command Completions
|
Adds completions for the command |
|
Removes all completions for the command |
|
Disables file completion for command |
|
Forces file completion for command |
|
Adds completions based on a specified condition. |
|
Adds a description for the completion. |
Useful Built-in Functions
|
Checks whether a specific argument has been used. |
|
Checks if a specific subcommand has been used. |
|
Checks if any subcommand is used. |
|
Completes directories. |
|
Completes files with a specific suffix. |
|
Lists all users for completion. |