â—Ź fish Configuration
fish configuration lives in ~/.config/fish/config.fish. Unlike bash/zsh, fish doesn't use . for sourcing files—use source instead.
Setup
Set fish as your default shell:
# Add fish to /etc/shells
echo /opt/homebrew/bin/fish | sudo tee -a /etc/shells
# Set as default shell
chsh -s /opt/homebrew/bin/fish
Basic Features
Syntax Highlighting
fish highlights commands as you type:
- Valid commands: green
- Invalid commands: red
- File paths: underlined
- Strings: yellow
Autosuggestions
fish suggests commands based on history:
- Gray text shows suggestions
- Press
→(right arrow) to accept - Press
ctrl + fto accept one character - Suggestions learn from your usage
Tab Completions
fish provides intelligent tab completion:
- Press
tabto see completions - Completions are context-aware
- Works with commands, flags, and file paths
Prompt Customization
Customize the prompt by modifying fish_prompt function:
function fish_prompt
set_color cyan
echo -n (whoami)
set_color white
echo -n "@"
set_color magenta
echo -n (hostname)
set_color green
echo -n " "(prompt_pwd)" "
set_color normal
echo -n "❯ "
end
Startup Configuration
Add to ~/.config/fish/config.fish:
# Starship prompt
starship init fish | source
# PATH
set -x PATH /opt/homebrew/bin $PATH
# Aliases
alias ll "ls -la"
alias gs "git status"
# Functions
if status is-interactive
# Interactive shell configuration
end
Plugins
Use Fisher for plugin management:
# Install Fisher
curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher
# Install plugins
fisher install jorgebucaran/autopair.fish
fisher install franciscolourenco/done
fisher install jethrokuan/z
Integration
With starship
starship init fish | source
With kitty
# Enable shell integration
set -gx KITTY_INSTALLATION_DIR "/Applications/kitty.app/Contents/Resources/kitty"
kitty + complete setup fish | source
Environment Variables
Set environment variables in config.fish:
# Set PATH
set -x PATH /opt/homebrew/bin $PATH
# Set editor
set -x EDITOR vim
# Set language
set -x LANG en_US.UTF-8
Aliases and Functions
Create custom aliases and functions:
# Simple alias
alias ll "ls -la"
# Function with arguments
function mkcd
mkdir -p $argv[1]
cd $argv[1]
end
fish configuration is straightforward and powerful, allowing extensive customization of your shell environment.
For fish commands and built-in functions, see fish Commands. For scripting details, see fish Scripting. For the main fish overview, see fish.
- Links to
- fish · starship · kitty · fish Commands · fish Scripting · fish
- Linked from
- fish · fish Commands · fish Scripting