12

I set up an alias:

alias gpgagentexport="eval $(cat ~/.gpg-agent-info) ; export GPG_AGENT_INFO"

However when I source my .bashrc the $(cat ...) is evaluated at that point. But I want to evaluate it when I run the alias gpgagentexport (after the contents of ~/.gpg-agent-info has changed).

So is there some sort of escaping, quoting or syntax to achieve that?

2 Answers 2

11

Use single quotes:

alias gpgagentexport='eval $(cat ~/.gpg-agent-info) ; export GPG_AGENT_INFO'
1
  • Ah, thank you. I should go and read a bit more about bash quoting rules. Apr 13, 2013 at 16:40
8

Escaping the $ should also work:

 alias gpgagentexport="eval \$(cat ~/.gpg-agent-info) ; export GPG_AGENT_INFO"
1
  • 1
    This answer worked better for me, as I had single quotes in my command.
    – fpnick
    Nov 20, 2018 at 9:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .