-
-
Save josephmidura/807770766aeb37b9cc3897e26f870210 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# Update homebrew | |
CYAN=$(tput setaf 6) | |
RESET=$(tput sgr0) | |
echo "${CYAN}Updating homebrew and local base of available packages and versions...${RESET}" | |
brew update | |
echo "${CYAN}Upgrading outdated homebrew packages...${RESET}" | |
brew upgrade | |
echo "${CYAN}Cleaning cache of unfinished downloads...${RESET}" | |
brew cleanup | |
echo "${CYAN}Checking for issues...${RESET}" | |
brew doctor |
@qns7 I'm glad you found it useful.
In your terminal, cd into the directory where you have your script saved. Make sure you have run chmod +x brewup
or chmod 755 brewup
there. If that location is ~/bin, and you can still not execute your script from any directory, you will also need to make sure the location where your scripts are stored is set in your $PATH environment variable (doesn't sound like it currently is). To add a new location to your $PATH, add the following to your .bashrc or .bash_profile:
PATH=$PATH:~/bin
export PATH
At that point, close and reopen your terminal and you should be set. You can verify the directory where you have brewup stored is now on your $PATH by typing this on the command line and verifying that "Users/your-username/bin" (if using a Mac) is one of the results you see:
echo "$PATH" | tr : '\n'
Thanks for the question - I've been working with shell scripts a lot lately and may write a new post or edit the existing one based on this.
Awesome, thank you!
In my case it was the .zprofile (on macOS Sonoma) and this did it. :)
I remembered the steps from Linux while following your steps, but that's years ago and I wouldn't have remembered it without your help:
I basically added 'username/bin' as a global callable directory by following your steps, so that I can call the script (scripts in general which are in any directoty listed in " echo "$PATH" | tr : '\n' ") from everywhere just by writing brewup. Right?
So again: Thank you. :)
Best regards Q
I'm glad it worked and it sounds like you're on the right track with calling scripts from directories in your $PATH.
Thank you for this! I just have one question: I basically copy-pasted everything you wrote form your Blog-Post, but unfortunately I'm not able to figure out how to define 'brewup' to get the script working from any directory by typing 'brewup'; I always have to type '~/bin/brewup' to do it. What am I missing here? I assume that's basic terminal/bash/...-stuff, but I have basically no knowledge here, so a reply from you would be very appreciated. :)