From ecd789a859422810827dbb253fe59b2b278ce2c6 Mon Sep 17 00:00:00 2001 From: Joshua Hamlet Date: Wed, 22 Mar 2023 23:54:20 -0700 Subject: [PATCH] check for existing aliases before adding new ones --- install.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 76f8a9f..f2bd104 100755 --- a/install.sh +++ b/install.sh @@ -19,12 +19,12 @@ alias computer=$TARGET_FULLPATH # Depends on your shell if [[ "$SHELL" == "/bin/bash" ]]; then echo "- Adding aliases to ~/.bash_aliases" - echo "alias yolo=$TARGET_FULLPATH" >> ~/.bash_aliases - echo "alias computer=$TARGET_FULLPATH" >> ~/.bash_aliases + [ "$(grep '^alias yolo=' ~/.bash_aliases)" ] && echo "alias yolo already created" || echo "alias yolo=$TARGET_FULLPATH" >> ~/.bash_aliases + [ "$(grep '^alias computer=' ~/.bash_aliases)" ] && echo "alias computer already created" || echo "alias computer=$TARGET_FULLPATH" >> ~/.bash_aliases elif [[ "$SHELL" == "/bin/zsh" ]]; then echo "- Adding aliases to ~/.zshrc" - echo "alias yolo=$TARGET_FULLPATH" >> ~/.zshrc - echo "alias computer=$TARGET_FULLPATH" >> ~/.zshrc + [ "$(grep '^alias yolo=' ~/.zshrc)" ] && echo "alias yolo already created" || echo "alias yolo=$TARGET_FULLPATH" >> ~/.zshrc + [ "$(grep '^alias computer=' ~/.zshrc)" ] && echo "alias computer already created" || echo "alias computer=$TARGET_FULLPATH" >> ~/.zshrc else echo "Note: Shell was not bash or zsh." echo " Consider configuring aliases (like yolo and/or computer) manually by adding them to your login script, e.g:" @@ -39,4 +39,4 @@ echo " - environment variable" echo " - .env or an ~/.openai.apikey file or in" echo " - yolo.yaml" echo -echo "Have fun!" \ No newline at end of file +echo "Have fun!"