18 lines
688 B
Bash
18 lines
688 B
Bash
#!/bin/bash
|
|
|
|
# ~/.bashrc pointed SSH_AUTH_SOCK at Bitwarden's SSH agent even when Bitwarden
|
|
# wasn't running it, which broke ssh and ssh-add for everyone else. Swap that
|
|
# line, where it was, for bitwarden.sh's, which only does so while it is.
|
|
OLD='export SSH_AUTH_SOCK="$HOME/.bitwarden-ssh-agent.sock"'
|
|
NEW='if [ -S "$HOME/.bitwarden-ssh-agent.sock" ]; then export SSH_AUTH_SOCK="$HOME/.bitwarden-ssh-agent.sock"; fi'
|
|
|
|
[ -f ~/.bashrc ] || exit 0
|
|
grep -qxF "$OLD" ~/.bashrc || exit 0
|
|
|
|
tmp="$(mktemp ~/.bashrc.XXXXXX)" || exit 1
|
|
awk -v old="$OLD" -v new="$NEW" '$0 == old { print new; next } { print }' ~/.bashrc > "$tmp" \
|
|
&& cat "$tmp" > ~/.bashrc
|
|
status=$?
|
|
rm -f "$tmp"
|
|
exit $status
|