Skip to content

Commit

Permalink
keybase: check PATH before altering .profile
Browse files Browse the repository at this point in the history
Don't ask to update .profile if PATH already includes our target directory.
  • Loading branch information
nabijaczleweli authored and flatcap committed Mar 18, 2022
1 parent 9d4458c commit 9b13a41
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions contrib/keybase/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ cp keybase.py "$HOME/.neomutt/keybaseMutt"
cp pgpdecrypt.sh decrypt.sh verify.sh pgpverify.sh "$HOME/.neomutt/keybaseMutt/scripts"

# Yay! Stuff's installed!
echo "You'll need to include '~/.neomutt/keybaseMutt/scripts' in your \$PATH."
echo "This can be done manually by installing in your ~/.profile."
echo "If you've done this previously on your computer, select 'n'."
echo "Do you want to proceed? [n]"
read -r shellInput
[ -n "$shellInput" ] && [ "$shellInput" != 'n' ] && echo 'PATH="$PATH:$HOME/.neomutt/keybaseMutt/scripts"' >> "$HOME/.profile"
if ! awk 'BEGIN {split(ENVIRON["PATH"], path, ":"); for(i = 1; i <= length(path); ++i) if(path[i] == (ENVIRON["HOME"] "/.neomutt/keybaseMutt/scripts")) exit 0; exit 1}'; then
echo "You'll need to include '~/.neomutt/keybaseMutt/scripts' in your \$PATH."
echo "This can be done manually by installing in your ~/.profile."
echo "If you've done this previously on your computer, select 'n'."
echo "Do you want to proceed? [n]"
read -r shellInput
[ -n "$shellInput" ] && [ "$shellInput" != 'n' ] && echo 'PATH="$PATH:$HOME/.neomutt/keybaseMutt/scripts"' >> "$HOME/.profile"
fi

echo "Please restart your shell to be able to use the scripts ('exec $SHELL' or reopening the terminal is easiest)."

0 comments on commit 9b13a41

Please sign in to comment.