Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Oh My Zsh
Commits
2a5321f4
Commit
2a5321f4
authored
Aug 31, 2016
by
mahi97
Browse files
add color echo
parent
92586e38
Changes
1
Hide whitespace changes
Inline
Side-by-side
plugins/osx/osx.plugin.zsh
View file @
2a5321f4
...
...
@@ -263,7 +263,7 @@ EOF
# Spotify control function
function
spotify
()
{
showHelp
()
{
echo
"Usage:"
;
echo
;
...
...
@@ -291,9 +291,16 @@ function spotify() {
echo
" toggle repeat # Toggles repeat playback mode."
;
}
cecho
(){
bold
=
$(
tput bold
)
;
green
=
$(
tput setaf 2
)
;
reset
=
$(
tput sgr0
)
;
echo
"
$bold$green$1$reset
"
;
}
showStatus
()
{
state
=
$(
osascript
-e
'tell application "Spotify" to player state as string'
)
;
echo
"Spotify is currently
$state
."
;
c
echo
"Spotify is currently
$state
."
;
if
[
"
$state
"
=
"playing"
]
;
then
artist
=
$(
osascript
-e
'tell application "Spotify" to artist of current track as string'
)
;
album
=
$(
osascript
-e
'tell application "Spotify" to album of current track as string'
)
;
...
...
@@ -307,6 +314,8 @@ function spotify() {
fi
}
if
[
$#
=
0
]
;
then
showHelp
;
else
...
...
@@ -321,50 +330,50 @@ function spotify() {
case
$arg
in
"play"
)
echo
"Playing Spotify."
;
c
echo
"Playing Spotify."
;
osascript
-e
'tell application "Spotify" to play'
;
break
;;
"pause"
)
echo
"Pausing Spotify."
;
c
echo
"Pausing Spotify."
;
osascript
-e
'tell application "Spotify" to pause'
;
break
;;
"quit"
)
echo
"Quitting Spotify."
;
c
echo
"Quitting Spotify."
;
osascript
-e
'tell application "Spotify" to quit'
;
exit
1
;;
"next"
)
echo
"Going to next track."
;
c
echo
"Going to next track."
;
osascript
-e
'tell application "Spotify" to next track'
;
break
;;
"prev"
)
echo
"Going to previous track."
;
c
echo
"Going to previous track."
;
osascript
-e
'tell application "Spotify" to previous track'
;
break
;;
"vol"
)
vol
=
$(
osascript
-e
'tell application "Spotify" to sound volume as integer'
)
;
if
[[
"
$2
"
=
"show"
||
"
$2
"
=
""
]]
;
then
echo
"Current Spotify volume level is
$vol
."
;
c
echo
"Current Spotify volume level is
$vol
."
;
break
;
elif
[
"
$2
"
=
"up"
]
;
then
if
[
"
$vol
"
-le
90
]
;
then
newvol
=
$((
vol+10
))
;
echo
"Increasing Spotify volume to
$newvol
."
;
c
echo
"Increasing Spotify volume to
$newvol
."
;
else
newvol
=
100
;
echo
"Spotify volume level is at max."
;
c
echo
"Spotify volume level is at max."
;
fi
elif
[
"
$2
"
=
"down"
]
;
then
if
[
"
$vol
"
-ge
10
]
;
then
newvol
=
$((
vol-10
))
;
echo
"Reducing Spotify volume to
$newvol
."
;
c
echo
"Reducing Spotify volume to
$newvol
."
;
else
newvol
=
0
;
echo
"Spotify volume level is at min."
;
c
echo
"Spotify volume level is at min."
;
fi
elif
[
"
$2
"
-ge
0
]
;
then
newvol
=
$2
;
...
...
@@ -377,16 +386,16 @@ function spotify() {
if
[
"
$2
"
=
"shuffle"
]
;
then
osascript
-e
'tell application "Spotify" to set shuffling to not shuffling'
;
curr
=
$(
osascript
-e
'tell application "Spotify" to shuffling'
)
;
echo
"Spotify shuffling set to
$curr
"
;
c
echo
"Spotify shuffling set to
$curr
"
;
elif
[
"
$2
"
=
"repeat"
]
;
then
osascript
-e
'tell application "Spotify" to set repeating to not repeating'
;
curr
=
$(
osascript
-e
'tell application "Spotify" to repeating'
)
;
echo
"Spotify repeating set to
$curr
"
;
c
echo
"Spotify repeating set to
$curr
"
;
fi
break
;;
"pos"
)
echo
"Adjusting Spotify play position."
c
echo
"Adjusting Spotify play position."
osascript
-e
"tell application
\"
Spotify
\"
to set player position to
$2
"
;
break
;;
...
...
@@ -431,8 +440,8 @@ function spotify() {
remove
=
'spotify:track:'
url
=
${
url
#
$remove
}
url
=
"http://open.spotify.com/track/
$url
"
echo
"Share URL:
$url
"
;
echo
-n
"
$url
"
| pbcopy
c
echo
"Share URL:
$url
"
;
c
echo
-n
"
$url
"
| pbcopy
break
;;
-h
|
--help
|
*
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment