Youssef Ameachaq's Blog

Youssef Ameachaq

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

💡 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:


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


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!