nushell / nushell.github.io

Nushell's main website, blog, book, and more
https://www.nushell.sh/book/
MIT License
162 stars 400 forks source link

Fix Keychain instructions in ssh_agent.md #1388

Closed justbispo closed 1 month ago

justbispo commented 2 months ago

Currently, the Keychain instructions in the cookbook don't work if you're trying to use GPG and SSH. The instructions assumes you're only using SSH.

With this change, it now removes the empty lines and uses the remaining ones, instead of only using the first 2.

Imo, ideally the page should also mention GPG. But my knowledge is superficial in this matter so I'll leave it to others.

fdncred commented 2 months ago

@amtoine Seems like you made the most recent changes to this file, iirc. Could you look over this PR and provide feedback or land it please?

amtoine commented 2 months ago

mm actually, i don't know nothing about keychain, i only wrote the SSH part above i think :confused: i'm using a slightly modified version of the Workaround section :yum:

amtoine commented 2 months ago

maybe if @justbispo can give a sample output of a keychain call, that'd be possible to see if the change is legit or not, otherwise i'm afraid i can't help much

justbispo commented 2 months ago

Sure, the command I have on my config is keychain --eval --quiet --noask -Q --agents gpg,ssh id_rsa id_ed25519 and the output is:

GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:1968:1; export GPG_AGENT_INFO;

SSH_AUTH_SOCK=/tmp/ssh-XXXXXXyd2dk5/agent.2138; export SSH_AUTH_SOCK;
SSH_AGENT_PID=2139; export SSH_AGENT_PID;
justbispo commented 2 months ago

That works too and it's much easier to understand than use the reduce. Also, can the call

load-env (
    ...
    )

be replaced with

    ...
    | load-env

to not use a different syntax of the first example of the page? It seems it can after testing it, but I'm still new to nushell so I'm just trying to be sure.

amtoine commented 1 month ago

@justbispo yeah,

{ FOO: "this is foo" } | load-env

and

load-env { FOO: "this is foo" }

yield the same results :ok_hand:

justbispo commented 1 month ago

@amtoine alright, thanks for your suggestion, just implemented it. Should be good to merge.