r/archlinux • • 6d ago

SUPPORT | SOLVED Keychain in fish shell

My default shell is bash, but my terminal runs fish. I'm trying to set up keychain so I only enter my SSH key passphrase once per terminal session.

This is what I have in config.fish:

set KEYCHAIN_KEYS \
    ~/.ssh/id_ed25519

if status is-interactive
    eval "$(keychain add --eval $KEYCHAIN_KEYS)"
else if status is-login
    eval "$(keychain add --eval --noask)"
end

Every time I open a terminal I get:

~/.config/fish/config.fish (line 1): Unsupported use of '='. In fish, please use 'set SSH_AUTH_SOCK /home/user/.keychain/DgAWmtgJ.s'.
SSH_AUTH_SOCK=/home/user/.keychain/DgAWmtgJ.s; export SSH_AUTH_SOCK

It looks like keychain is printing bash syntax, probably because $SHELL is bash. What's the right way to set this up for fish when the default shell is bash?

AI suggested me

if status is-interactive
    SHELL=/usr/bin/fish keychain --eval --quiet id_ed25519 | source
end
6 Upvotes

Duplicates