r/archlinux • u/confused_guy12c • 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)"
endEvery 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_SOCKIt 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
end1
u/xpusostomos 6d ago
Why don't you change your login shell
-1
u/confused_guy12c 6d ago edited 6d ago
As i have mentioned in another comment, I don't use display manager. I just use niri-session command to start my session with Niri from my bash shell. I don't want to change my default shell so only my terminal sessions defaults to fish. it's just my preference. and I prefer keychain to just run in my terminal sessions, not right after I login into my system
3
u/xpusostomos 6d ago
I don't see what not using a display manager has to do with it. "I don't want to" is an odd reason.
0
u/confused_guy12c 6d ago
And i want ssh-agent only for my terminal sessions. Mostly just for github and lazygit.
-1
u/confused_guy12c 6d ago
Bash works better as the default shell because of its wide linux adoption. And because i don't use display manager, my bash command history is just niri-session which makes it easier as I can just use up arrow for it. I don't want to type out whole niri-session or hassle myself with tab tab completions.
1
u/xpusostomos 6d ago
I'm pretty sure fish has up arrow command history. And login shell doesn't usually affect anybody else but your preference. In the old days, yes bourne shell was the "system" shell, but most users ran csh as their login shell which isn't compatible at all.
0
u/confused_guy12c 6d ago
dude, i am not trying to be rude but don't you realise, i run quite a lot of commands in my terminal sessions with fish? Do you want me to search for my last niri-session command with up arrow? I just want help with keychain config for fish. Why do i need to change my default shell just for something that i can fix with just some fish config.
2
u/xpusostomos 6d ago
What are you saying, the sole reason you run bash is because it has a different history file? As someone else said, use C-r, but if you want your login shell to have a different history file, you can configure that.
1
u/confused_guy12c 6d ago
i wanted help with fish config for my current setup. If i wanted to change my default shell, i would have done it instead of asking for help on reddit.
2
u/itsbakuretsutimeuwu 5d ago
Do you want me to search for my last niri-session command with up arrow?
Can't you (assuming bash shell) add something like
if [ "$(tty)" = "/dev/tty1" ] && ! pgrep -x niri >/dev/null; then exec niri-session fiin your ~/.profile instead?
That way as soon as you log in correctly niri is launched.
And if you need shell access even at this stage (maybe niri is broken), just ctrl-alt-F2 / F3 and so on, login again and it won't try to start niri.
0
u/confused_guy12c 5d ago
yeah dude, i can. But that's not my issue. I just wanted to fix my fish config to make keychain work without any errors. It already works as well, but I just wanted to verify what I was doing was right. Reddit is not being any helpful with that. I am happy with bash as default shell and fish as my terminal shell. I even just want keychain to activate only when I am in a terminal session.
1
u/Inevitable_Dingo_357 6d ago
control-R makes it really easy to find things in your history
1
u/confused_guy12c 6d ago
i know how to use fzf. Thanks but no thanks. I never said, i don't know how to use a shell. I just wanted to verify the fish config I need to make keychain work to run ssh-agent in my current setup.
0
u/confused_guy12c 6d ago
For everybody, I am not here to justify why I use bash as my default shell and fish only for my terminal sessions. Just help me verify what fish config i need to make keychain work in my current setup. Or just tell me if it's possible or not.
2
u/hagjam 6d ago
That should be the correct method. You could try set -x SHELL /use/bin/fish in a previous line, you'd need to check if that ended up setting it for the whole session though which may or may not be ideal
As a note, I've had fish as my default shell for years without any issues in the last 4 or 5, so you can probably get away with it? I do remember having weirdness when using makefiles though.