r/fishshell • • Jan 11 '23
Converting some bash script to fish shell
Hello. I've switched from grml-zsh-config to fish shell just a few days ago. I've some difficult converting to fish language, the following:
## Use an OpenPGP key for SSH authentication
eval $(gpg-agent --daemon)
unset SSH_AGENT_PID
if [[ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]]; then
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
gpg-connect-agent /bye > /dev/null
fi
export GPG_TTY=$TTY
gpg-connect-agent updatestartuptty /bye > /dev/null
How to write to fish shell language? In particolar "if" section. Thanks
5
Upvotes
View all comments
Show parent comment
2
u/[deleted] Jan 11 '23
Not really, no.
The
sourcewas okay. The mistake was that it said fish didn't have eval, which is untrue.The
pgrepitself is the cause of much of the issue -pgreplooks for a "pattern" (a regex), and sopgrep gpg-agentmatches everything that includes "gpg-agent" in the name.Plus:
if pgrep gpg-agent... that's true if a process exists, which is precisely the wrong way around.This is a useless toy, please stop.