diff --git a/plugins.d/homebrew.sh b/plugins.d/homebrew.sh index 1ead821..06a02d9 100755 --- a/plugins.d/homebrew.sh +++ b/plugins.d/homebrew.sh @@ -9,26 +9,27 @@ # 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 +# Casks don't have pinned cask. So add Cask to the do_not_update array for prevent to update. +# Also add package for prevent to update whitout pin it. 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 +# -jq (Lightweight and flexible command-line JSON processor) +# -terminal-notifier (Send macOS User Notifications from the command-line) # -######################################### +############################################################################################### notification() { sound="Basso" @@ -49,11 +50,11 @@ fi echo -e "\033[1m🍺 Homebrew \033[0m" -#brew update +brew update echo "" -# pinned +# Pinned packages brew_pinned=$(brew list --pinned) @@ -68,25 +69,16 @@ if [ -n "$brew_pinned" ]; then fi -# Un paquet pinned est dans 'brew outdated' +# A pinned package is in 'brew outdated' -if [ -x "$(command -v jqs)" ]; then - brew_outdated=$(brew outdated --json) - - upd3=$(echo "$brew_outdated" ) - +if [ -x "$(command -v jq)" ]; then + brew_outdated=$(brew outdated --json) + upd3=$(echo "$brew_outdated" ) else - brew_outdated=$(brew outdated) - - upd3=$(echo "$brew_outdated" | awk '{print $1}') - + 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 @@ -94,85 +86,20 @@ if [ -n "$upd3" ]; then if [ "$display_info" = true ]; then echo -e "\033[4mInfo on updated packages:\033[0m" - if [ -x "$(command -v jqs)" ]; then + if [ -x "$(command -v jq)" ]; 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"'); + 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" - -<