Skip to content

Commit d0d1fa4

Browse files
Refactor export GPG_TTY command to add line break
The command to add `GPG_TTY` does not update the shell config correctly if the file ends in a comment. I previously installed pnpm so running the command changed my `.zshrc` file to: ``` #pnpm endexport GPG_TTY=$(tty) ``` Fixed by updating each instance of the command to: ``` echo -e '\nexport GPG_TTY=\$(tty)' ```
1 parent fcf54ec commit d0d1fa4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

content/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ If you have multiple GPG keys, you need to tell Git which one to use.
3939
{% data reusables.gpg.set-auto-sign %}
4040
1. If you aren't using the GPG suite, run the following command in the `zsh` shell to add the GPG key to your `.zshrc` file, if it exists, or your `.zprofile` file:
4141
```shell
42-
$ if [ -r ~/.zshrc ]; then echo 'export GPG_TTY=$(tty)' >> ~/.zshrc; \
43-
else echo 'export GPG_TTY=$(tty)' >> ~/.zprofile; fi
42+
$ if [ -r ~/.zshrc ]; then echo -e '\nexport GPG_TTY=\$(tty)' >> ~/.zshrc; \
43+
else echo -e '\nexport GPG_TTY=\$(tty)' >> ~/.zprofile; fi
4444
```
4545
Alternatively, if you use the `bash` shell, run this command:
4646
```shell
47-
$ if [ -r ~/.bash_profile ]; then echo 'export GPG_TTY=$(tty)' >> ~/.bash_profile; \
48-
else echo 'export GPG_TTY=$(tty)' >> ~/.profile; fi
47+
$ if [ -r ~/.bash_profile ]; then echo -e '\nexport GPG_TTY=\$(tty)' >> ~/.bash_profile; \
48+
else echo -e '\nexport GPG_TTY=\$(tty)' >> ~/.profile; fi
4949
```
5050
1. Optionally, to prompt you to enter a PIN or passphrase when required, install `pinentry-mac`. For example, using [Homebrew](https://brew.sh/):
5151
```shell
@@ -97,7 +97,7 @@ If you have multiple GPG keys, you need to tell Git which one to use.
9797
{% data reusables.gpg.set-auto-sign %}
9898
1. To add your GPG key to your `.bashrc` startup file, run the following command:
9999
```bash
100-
$ [ -f ~/.bashrc ] && echo 'export GPG_TTY=$(tty)' >> ~/.bashrc
100+
$ [ -f ~/.bashrc ] && echo -e '\nexport GPG_TTY=\$(tty)' >> ~/.bashrc
101101
```
102102
{% endlinux %}
103103
{% ifversion ssh-commit-verification %}

0 commit comments

Comments
 (0)