Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
2a5321f4
Commit
2a5321f4
authored
Aug 30, 2016
by
mahi97
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add color echo
parent
92586e38
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
17 deletions
+26
-17
osx.plugin.zsh
plugins/osx/osx.plugin.zsh
+26
-17
No files found.
plugins/osx/osx.plugin.zsh
View file @
2a5321f4
...
@@ -263,7 +263,7 @@ EOF
...
@@ -263,7 +263,7 @@ EOF
# Spotify control function
# Spotify control function
function
spotify
()
{
function
spotify
()
{
showHelp
()
{
showHelp
()
{
echo
"Usage:"
;
echo
"Usage:"
;
echo
;
echo
;
...
@@ -291,9 +291,16 @@ function spotify() {
...
@@ -291,9 +291,16 @@ function spotify() {
echo
" toggle repeat # Toggles repeat playback mode."
;
echo
" toggle repeat # Toggles repeat playback mode."
;
}
}
cecho
(){
bold
=
$(
tput bold
)
;
green
=
$(
tput setaf 2
)
;
reset
=
$(
tput sgr0
)
;
echo
"
$bold$green$1$reset
"
;
}
showStatus
()
{
showStatus
()
{
state
=
$(
osascript
-e
'tell application "Spotify" to player state as string'
)
;
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
if
[
"
$state
"
=
"playing"
]
;
then
artist
=
$(
osascript
-e
'tell application "Spotify" to artist of current track as string'
)
;
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'
)
;
album
=
$(
osascript
-e
'tell application "Spotify" to album of current track as string'
)
;
...
@@ -307,6 +314,8 @@ function spotify() {
...
@@ -307,6 +314,8 @@ function spotify() {
fi
fi
}
}
if
[
$#
=
0
]
;
then
if
[
$#
=
0
]
;
then
showHelp
;
showHelp
;
else
else
...
@@ -321,50 +330,50 @@ function spotify() {
...
@@ -321,50 +330,50 @@ function spotify() {
case
$arg
in
case
$arg
in
"play"
)
"play"
)
echo
"Playing Spotify."
;
c
echo
"Playing Spotify."
;
osascript
-e
'tell application "Spotify" to play'
;
osascript
-e
'tell application "Spotify" to play'
;
break
;;
break
;;
"pause"
)
"pause"
)
echo
"Pausing Spotify."
;
c
echo
"Pausing Spotify."
;
osascript
-e
'tell application "Spotify" to pause'
;
osascript
-e
'tell application "Spotify" to pause'
;
break
;;
break
;;
"quit"
)
"quit"
)
echo
"Quitting Spotify."
;
c
echo
"Quitting Spotify."
;
osascript
-e
'tell application "Spotify" to quit'
;
osascript
-e
'tell application "Spotify" to quit'
;
exit
1
;;
exit
1
;;
"next"
)
"next"
)
echo
"Going to next track."
;
c
echo
"Going to next track."
;
osascript
-e
'tell application "Spotify" to next track'
;
osascript
-e
'tell application "Spotify" to next track'
;
break
;;
break
;;
"prev"
)
"prev"
)
echo
"Going to previous track."
;
c
echo
"Going to previous track."
;
osascript
-e
'tell application "Spotify" to previous track'
;
osascript
-e
'tell application "Spotify" to previous track'
;
break
;;
break
;;
"vol"
)
"vol"
)
vol
=
$(
osascript
-e
'tell application "Spotify" to sound volume as integer'
)
;
vol
=
$(
osascript
-e
'tell application "Spotify" to sound volume as integer'
)
;
if
[[
"
$2
"
=
"show"
||
"
$2
"
=
""
]]
;
then
if
[[
"
$2
"
=
"show"
||
"
$2
"
=
""
]]
;
then
echo
"Current Spotify volume level is
$vol
."
;
c
echo
"Current Spotify volume level is
$vol
."
;
break
;
break
;
elif
[
"
$2
"
=
"up"
]
;
then
elif
[
"
$2
"
=
"up"
]
;
then
if
[
"
$vol
"
-le
90
]
;
then
if
[
"
$vol
"
-le
90
]
;
then
newvol
=
$((
vol+10
))
;
newvol
=
$((
vol+10
))
;
echo
"Increasing Spotify volume to
$newvol
."
;
c
echo
"Increasing Spotify volume to
$newvol
."
;
else
else
newvol
=
100
;
newvol
=
100
;
echo
"Spotify volume level is at max."
;
c
echo
"Spotify volume level is at max."
;
fi
fi
elif
[
"
$2
"
=
"down"
]
;
then
elif
[
"
$2
"
=
"down"
]
;
then
if
[
"
$vol
"
-ge
10
]
;
then
if
[
"
$vol
"
-ge
10
]
;
then
newvol
=
$((
vol-10
))
;
newvol
=
$((
vol-10
))
;
echo
"Reducing Spotify volume to
$newvol
."
;
c
echo
"Reducing Spotify volume to
$newvol
."
;
else
else
newvol
=
0
;
newvol
=
0
;
echo
"Spotify volume level is at min."
;
c
echo
"Spotify volume level is at min."
;
fi
fi
elif
[
"
$2
"
-ge
0
]
;
then
elif
[
"
$2
"
-ge
0
]
;
then
newvol
=
$2
;
newvol
=
$2
;
...
@@ -377,16 +386,16 @@ function spotify() {
...
@@ -377,16 +386,16 @@ function spotify() {
if
[
"
$2
"
=
"shuffle"
]
;
then
if
[
"
$2
"
=
"shuffle"
]
;
then
osascript
-e
'tell application "Spotify" to set shuffling to not shuffling'
;
osascript
-e
'tell application "Spotify" to set shuffling to not shuffling'
;
curr
=
$(
osascript
-e
'tell application "Spotify" to 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
elif
[
"
$2
"
=
"repeat"
]
;
then
osascript
-e
'tell application "Spotify" to set repeating to not repeating'
;
osascript
-e
'tell application "Spotify" to set repeating to not repeating'
;
curr
=
$(
osascript
-e
'tell application "Spotify" to repeating'
)
;
curr
=
$(
osascript
-e
'tell application "Spotify" to repeating'
)
;
echo
"Spotify repeating set to
$curr
"
;
c
echo
"Spotify repeating set to
$curr
"
;
fi
fi
break
;;
break
;;
"pos"
)
"pos"
)
echo
"Adjusting Spotify play position."
c
echo
"Adjusting Spotify play position."
osascript
-e
"tell application
\"
Spotify
\"
to set player position to
$2
"
;
osascript
-e
"tell application
\"
Spotify
\"
to set player position to
$2
"
;
break
;;
break
;;
...
@@ -431,8 +440,8 @@ function spotify() {
...
@@ -431,8 +440,8 @@ function spotify() {
remove
=
'spotify:track:'
remove
=
'spotify:track:'
url
=
${
url
#
$remove
}
url
=
${
url
#
$remove
}
url
=
"http://open.spotify.com/track/
$url
"
url
=
"http://open.spotify.com/track/
$url
"
echo
"Share URL:
$url
"
;
c
echo
"Share URL:
$url
"
;
echo
-n
"
$url
"
| pbcopy
c
echo
-n
"
$url
"
| pbcopy
break
;;
break
;;
-h
|
--help
|
*
)
-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