#!/usr/bin/env bash # Homebrew plugin for KYMSU # https://github.com/welcoMattic/kymsu # Error: Cask 'onyx' definition is invalid: invalid 'depends_on macos' value: :snow_leopard # Supprimer manuellement onyx de /Applications # rm -rvf "$(brew --prefix)/Caskroom/onyx" # ou # /usr/bin/find "$(brew --prefix)/Caskroom/"*'/.metadata' -type f -name '*.rb' -print0 | /usr/bin/xargs -0 /usr/bin/perl -i -0pe 's/depends_on macos: \[.*?\]//gsm;s/depends_on macos: .*//g' ######################################### # # Settings: # Display info on updated pakages display_info=true #add Cask to do_not_update array declare -a do_not_update=('') # No distract mode (no user interaction)(Casks with 'latest' version number won't be updated) no_distract=false # ######################################### # # Recommended software (brew install): # -jq # -terminal-notifier # ######################################### notification() { sound="Basso" title="Homebrew" #subtitle="Attention !!!" message="$1" image="error.png" if [[ "$OSTYPE" == "darwin"* ]] && [ -x "$(command -v terminal-notifier)" ]; then terminal-notifier -title "$title" -message "$message" -sound "$sound" -contentImage "$image" fi } if [[ $1 == "--nodistract" ]]; then no_distract=true fi echo -e "\033[1m🍺 Homebrew \033[0m" #brew update echo "" # pinned brew_pinned=$(brew list --pinned) if [ -n "$brew_pinned" ]; then echo -e "\033[4mList of pinned packages:\033[0m" pinned=$(echo "$brew_pinned" | tr '\n' ' ') echo -e "\033[1;31m️$pinned\033[0m" echo "To update a pinned package, you need to un-pin it manually (brew unpin )" echo "" fi # Un paquet pinned est dans 'brew outdated' if [ -x "$(command -v jqs)" ]; then brew_outdated=$(brew outdated --json) upd3=$(echo "$brew_outdated" ) else brew_outdated=$(brew outdated) upd3=$(echo "$brew_outdated" | awk '{print $1}') fi #upd3=$(echo "$brew_outdated" | awk '{print $1}') #upd3=$(echo "$brew_outdated" ) echo "$upd3" if [ -n "$upd3" ]; then # Display info on outdated packages if [ "$display_info" = true ]; then echo -e "\033[4mInfo on updated packages:\033[0m" if [ -x "$(command -v jqs)" ]; then # ok avec jq installé for row in $(jq -c '.[]' <<< "$upd3"); do #echo ${row} # = echo "$row" if [ -x "$(command -v jq)" ]; then name=$(echo "$row" | jq -j '.name, "\n"'); pinned=$(echo "$row" | jq -j '.pinned, "\n"'); pinned_v=$(echo "$row" | jq -j '.pinned_version, "\n"'); iv=$(echo "$row" | jq -j '.installed_versions, "\n"'); installed_v=$(echo "$iv" | jq -j '.[]'); #echo "$iv" current_v=$(echo "$row" | jq -j '.current_version, "\n"'); #info_pkg=$(brew info --json=v1 "$name") homepage=$(echo "$info_pkg" | jq -r .[].homepage) desc=$(echo "$info_pkg" | jq -r .[].desc) #current=$(echo "$info_pkg" | jq -r .[].installed[].version | tail -n 1 | awk '{print $1}') #stable=$(echo "$info_pkg" | jq -r .[].versions.stable) #pined=$(echo "$info_pkg" | jq -r .[].pinned) if [ "$pinned" = "true" ]; then echo -e "\033[1;31m$name: installed: $installed_v stable: $current_v [pinned at $pinned_v]\033[0m"; else echo -e "\033[1;37m$name: installed: $installed_v stable: $current_v\033[0m"; fi echo "$desc" echo "$homepage" echo "" fi done else # test sans jq for pkg in "$upd3" do echo "$pkg" echo "---" #info=$(brew info "$pkg") #echo "$info" <