Fish shell
Fish shell is powerful and user-friendly. Here are some pro tips to make the most of it:
1. Enable Syntax Highlighting & Autosuggestions
- Fish provides command completion and syntax highlighting out of the box.
- Gray text → Fish suggests based on history.
- Red text → Invalid command.
💡 Use the right arrow key (→) to accept suggestions.
2. Abbreviations for Quick Commands
Instead of aliases, Fish uses abbreviations, which expand into full commands when you press Space or Enter.
abbr -a gs "git status"
abbr -a gl "git log --oneline --graph --decorate"
abbr -a venv "source venv/bin/activate"
Now, typing gs expands into git status.
🔥 Abbreviations persist across sessions!
3. Universal Variables (Persist Across Sessions)
To set a persistent environment variable:
set -Ux MY_VAR "Hello"
To remove it:
set -Ue MY_VAR
4. Faster Navigation with cd Alternatives
Instead of typing full paths:
cd -→ Go back to the previous directory.cd ..→ Move one level up.- Use
~for the home directory:cd ~/Projects/myrepo - Enable directory autosuggestions:
Just type a few letters and hitTab.
5. Fish Functions for Custom Commands
Functions let you define reusable commands:
function ll
ls -lh $argv
end
Now, ll works like ls -lh. To make it persistent:
funcsave ll
6. Powerful History Search
- Use
Ctrl + Rfor reverse search. - Start typing a command and use
↑and↓to scroll through history.
7. Auto-Load Environment Variables from a File
If you want to store variables separately, create a file:
nano ~/.config/fish/env.fish
Add:
set -x MY_VAR "Hello"
Then, in ~/.config/fish/config.fish, load it:
source ~/.config/fish/env.fish
8. Speed Up Fish with Fisher (Plugin Manager)
Install Fisher (a Fish package manager):
curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher
Install plugins like:
fisher install PatrickF1/fzf.fish # Fuzzy search
fisher install jethrokuan/z # Auto-jump to recent directories
9. Use z for Faster Navigation
fisher install jethrokuan/z
Now, just type:
z myproject
It will jump to ~/Projects/myproject automatically!
10. Enable Vi Keybindings (If You Like Vim)
fish_vi_key_bindings
Now, you can use Esc to switch between Normal/Insert modes.
Bonus: Customize Your Prompt
Use Starship for a beautiful prompt:
brew install starship
echo 'starship init fish | source' >> ~/.config/fish/config.fish
Restart Fish, and enjoy a fast, modern prompt!