2a5321f4e69b55f626c94993a40b1dee6a73c26f

Author
mahi97 <mohammadmahdi76@gmail.com>
Committer
mahi97 <mohammadmahdi76@gmail.com>
Date

Message

add color echo

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh
  2index dc68916bf69c2a84b81b37715cab12ef6261286e..19acd3dd5484e858ea47bec7ac3519e088210929 100644
  3--- a/plugins/osx/osx.plugin.zsh
  4+++ b/plugins/osx/osx.plugin.zsh
  5@@ -263,7 +263,7 @@ EOF
  6 
  7 # Spotify control function
  8 function spotify() {
  9-  
 10+
 11   showHelp () {
 12     echo "Usage:";
 13     echo;
 14@@ -291,9 +291,16 @@ function spotify() {
 15     echo "  toggle repeat                # Toggles repeat playback mode.";
 16   }
 17 
 18+  cecho(){
 19+    bold=$(tput bold);
 20+    green=$(tput setaf 2);
 21+    reset=$(tput sgr0);
 22+    echo "$bold$green$1$reset";
 23+  }
 24+
 25   showStatus () {
 26       state=$(osascript -e 'tell application "Spotify" to player state as string');
 27-      echo "Spotify is currently $state.";
 28+      cecho "Spotify is currently $state.";
 29       if [ "$state" = "playing" ]; then
 30         artist=$(osascript -e 'tell application "Spotify" to artist of current track as string');
 31         album=$(osascript -e 'tell application "Spotify" to album of current track as string');
 32@@ -307,6 +314,8 @@ function spotify() {
 33       fi
 34   }
 35 
 36+
 37+
 38   if [ $# = 0 ]; then
 39     showHelp;
 40   else
 41@@ -321,50 +330,50 @@ function spotify() {
 42 
 43     case $arg in
 44       "play"    )
 45-        echo "Playing Spotify.";
 46+        cecho "Playing Spotify.";
 47         osascript -e 'tell application "Spotify" to play';
 48         break ;;
 49 
 50       "pause"    )
 51-        echo "Pausing Spotify.";
 52+        cecho "Pausing Spotify.";
 53         osascript -e 'tell application "Spotify" to pause';
 54         break ;;
 55 
 56       "quit"    ) 
 57-        echo "Quitting Spotify.";
 58+        cecho "Quitting Spotify.";
 59         osascript -e 'tell application "Spotify" to quit';
 60         exit 1 ;;
 61 
 62       "next"    ) 
 63-        echo "Going to next track." ;
 64+        cecho "Going to next track." ;
 65         osascript -e 'tell application "Spotify" to next track';
 66         break ;;
 67 
 68       "prev"    ) 
 69-        echo "Going to previous track.";
 70+        cecho "Going to previous track.";
 71         osascript -e 'tell application "Spotify" to previous track';
 72         break ;;
 73 
 74       "vol"    )
 75         vol=$(osascript -e 'tell application "Spotify" to sound volume as integer');
 76         if [[ "$2" = "show" || "$2" = "" ]]; then
 77-          echo "Current Spotify volume level is $vol.";
 78+          cecho "Current Spotify volume level is $vol.";
 79           break ;
 80         elif [ "$2" = "up" ]; then
 81           if [ "$vol" -le 90 ]; then
 82             newvol=$(( vol+10 ));
 83-            echo "Increasing Spotify volume to $newvol.";
 84+            cecho "Increasing Spotify volume to $newvol.";
 85           else
 86             newvol=100;
 87-            echo "Spotify volume level is at max.";
 88+            cecho "Spotify volume level is at max.";
 89           fi
 90         elif [ "$2" = "down" ]; then
 91           if [ "$vol" -ge 10 ]; then
 92             newvol=$(( vol-10 ));
 93-            echo "Reducing Spotify volume to $newvol.";
 94+            cecho "Reducing Spotify volume to $newvol.";
 95           else
 96             newvol=0;
 97-            echo "Spotify volume level is at min.";
 98+            cecho "Spotify volume level is at min.";
 99           fi
100         elif [ "$2" -ge 0 ]; then
101           newvol=$2;
102@@ -377,16 +386,16 @@ function spotify() {
103         if [ "$2" = "shuffle" ]; then
104           osascript -e 'tell application "Spotify" to set shuffling to not shuffling';