● fish Commands
fish provides intuitive commands for navigation, history, and variable management.
Navigation
# Directory navigation
cd # Change directory
cd .. # Parent directory
cd - # Previous directory
pushd . # Push directory to stack
popd # Pop directory from stack
History
# History navigation
↑ / ↓ # Navigate history
ctrl + r # Search history
alt + ↑ / ↓ # Navigate by directory
history # Show history
Variables
# Set variables
set NAME value # Local variable
set -x NAME value # Export variable
set -U NAME value # Universal variable (persistent)
# Use variables
echo $NAME
Functions
# Define function
function hello
echo "Hello, world!"
end
# Call function
hello
# List functions
functions
# Edit function
funced hello
Aliases
Create aliases in ~/.config/fish/functions/ or directly in config:
# Simple alias
alias ll "ls -la"
# Function with arguments
function mkcd
mkdir -p $argv[1]
cd $argv[1]
end
Useful Built-in Functions
# Show file contents with syntax highlighting
highlight file.py
# Extract various archive formats
extract file.tar.gz
# Quick directory navigation
z # Jump to frequently used directories
z marks # Show all marks
# Git integration
git status # Enhanced git status
Environment Variables
# Set PATH
set -x PATH /opt/homebrew/bin $PATH
# Set editor
set -x EDITOR vim
# Set language
set -x LANG en_US.UTF-8
Universal Variables
Universal variables persist across sessions:
# Set universal variable
set -U EDITOR vim
# List universal variables
set -U
# Export universal variable
set -Ux PATH /opt/homebrew/bin $PATH
Special Variables
# Command line arguments
$argv # All arguments
$argv[1] # First argument
$argv[-1] # Last argument
# Exit status
$status # Exit status of last command
# Process ID
$fish_pid # Fish process ID
fish commands are designed to be intuitive and consistent, making shell interaction more efficient.
For fish configuration and setup, see fish Configuration. For scripting details, see fish Scripting. For the main fish overview, see fish.
- Links to
- fish · fish Configuration · fish Scripting · fish
- Linked from
- fish Scripting · fish · fish Configuration