Skip to content

Fish Shell Setupโš“๏ธŽ

Setup Fish Shellโš“๏ธŽ

Fish is a smart & user-friendly command line shell for Linux, macOS, and the rest of the family. Unlike other shells, which disable certain features by default to save system resources, Fish enables all features by defaultโ€”finally, a command line shell for the 90s!

A curation of plugins, prompts, and other treasures for the friendly interactive shell. This page is not an official Fish project. We do not to advertise for profit. Want to have your project featured here? Send us a pull request.

Official Resourcesโš“๏ธŽ

Community Resourcesโš“๏ธŽ


Install Fishโš“๏ธŽ

sudo pacman -S fish
chsh -s $(which fish)
fish_add_path -m ~/.local/bin
sudo apt-add-repository ppa:fish-shell/release-4
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install fish
chsh -s $(which fish)
fish_add_path -m ~/.local/bin

Fontsโš“๏ธŽ

Nerd-Fonts - Iconic font aggregator, collection, & patcherโš“๏ธŽ

Install FiraCode

git clone --filter=blob:none --sparse https://github.com/ryanoasis/nerd-fonts
cd nerd-fonts
git sparse-checkout add patched-fonts/FiraCode
./install.sh FiraCode

Pluginsโš“๏ธŽ

Fisher - Manage functions, completions, bindings, and snippets from the CLIโš“๏ธŽ

curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher

fzf - Ef-๐ŸŸ-ient key bindings for junegunn/fzf. (Alternative)โš“๏ธŽ

Install dependencies

git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
paru -S cachyos-extra-v3/fd
sudo apt install fd-find
ln -s $(which fdfind) ~/.local/bin/fd
paru -S cachyos-extra-v3/bat
sudo apt install bat
ln -s /usr/bin/batcat ~/.local/bin/bat

Finally install fzf with Fisher

fisher install PatrickF1/fzf.fish

Sponge - Clean command history from typos automaticallyโš“๏ธŽ

fisher install meaningful-ooo/sponge
โ›” Purge only on exitโš“๏ธŽ

Sometimes you want to ignore sponge_delay variable and access the whole history of the current session. In such cases you can instruct Sponge to purge entries only on shell exit with sponge_purge_only_on_exit variable:

set sponge_purge_only_on_exit true

Autopair - Auto-complete matching pairs in the Fish command-line. (Alternative)โš“๏ธŽ

fisher install jorgebucaran/autopair.fish

Getopts - CLI options parser (alternative to the argparse builtin)โš“๏ธŽ

fisher install jorgebucaran/getopts.fish

PyEnvโš“๏ธŽ

Install pyenv:

curl -fsSL https://pyenv.run | bash

Configure fish shell to use pyenv:

set -Ux PYENV_ROOT $HOME/.pyenv
test -d $PYENV_ROOT/bin; and fish_add_path $PYENV_ROOT/bin

Install a pyenv fisher plugin to setup completions and shell integration:

fisher install amir20/fish-pyenv 

Promptsโš“๏ธŽ

Tide - A modern prompt manager for Fishโš“๏ธŽ

fisher install IlanCosman/tide@v6

Extra Modificationsโš“๏ธŽ

Multiplexer (Byobu)โš“๏ธŽ

https://alexsavio.github.io/how-to-byobu.html

  • Install byobu
sudo pacman -S byobu
sudo apt install byobu
  • Start byobu on login
byobu-enable
  • Enable mouse in byobu
  • Create/open ~/.byobu/profile.tmux and add the following lines

    source $BYOBU_PREFIX/share/byobu/profiles/tmux
    
    ## Make mouse useful, tmux > 2.1 include select, resize pane/window and console wheel scroll
    set -g mouse on
    
    ## Lower escape timing from 500ms to 50ms for quicker response to scroll-buffer access
    set -s escape-time 50
    

    rodricels/.tmux.conf

Custom Fish Keybindingsโš“๏ธŽ

  • Delete next word with Ctrl + Delete and previous word with Ctrl + Backspace
  • Open ~/.config/fish/functions/fish_user_key_bindings.fish and add the following lines within the function

    bind \x7f backward-delete-char  # Normal Backspace deletes characters
    bind \b backward-kill-word      # Ctrl+Backspace deletes words
    
    bind \e\[3\;5~ kill-word  # Bind Ctrl+Delete to delete the next word
    

Note

Termius on iOS registers both backspace and ctrl + backspace with the same keycode ^H.
So, you may want to skip the backspace keybindings.

You can check what your terminal gets on a keypress by entering cat
and pressing the key you want to check.

Keychain (ssh-agent)โš“๏ธŽ

https://superuser.com/a/1727657

  • Install keychain:
sudo pacman -S keychain
sudo apt install keychain
  • Add these lines to ~/.config/fish/conf.d/keychain.fish:

    if status is-login
        and status is-interactive
        # To add a key, set -Ua SSH_KEYS_TO_AUTOLOAD keypath
        # To remove a key, set -U --erase SSH_KEYS_TO_AUTOLOAD[index_of_key]
        keychain --eval $SSH_KEYS_TO_AUTOLOAD | source
    
    end
    

    Tip

    SSH_KEYS_TO_AUTOLOAD is an array of key paths to be loaded by keychain.
    You can add or remove keys from the array as needed.

    Add multiple keys to SSH_KEYS_TO_AUTOLOAD array

    set -Ua SSH_KEYS_TO_AUTOLOAD ~/.ssh/{key1,key1.pub,key2,key2.pub}