Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
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
b8085556
Commit
b8085556
authored
Aug 30, 2016
by
mahi97
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add search option for playlist
parent
3b2f827d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
6 deletions
+29
-6
osx.plugin.zsh
plugins/osx/osx.plugin.zsh
+29
-6
No files found.
plugins/osx/osx.plugin.zsh
View file @
b8085556
...
...
@@ -350,6 +350,29 @@ function spotify() {
}
case
$2
in
"list"
)
_args
=
${
array
[*]
:2:
$len
}
;
Q
=
$_args
;
cecho
"Searching playlists for:
$Q
"
;
results
=
$(
\
curl
-s
-G
$SPOTIFY_SEARCH_API
--data-urlencode
"q=
$Q
"
-d
"type=playlist&limit=10&offset=0"
-H
"Accept: application/json"
\
|
grep
-E
-o
"spotify:user:[a-zA-Z0-9_]+:playlist:[a-zA-Z0-9]+"
-m
10
\
)
count
=
$(
\
echo
"
$results
"
|
grep
-c
"spotify:user"
\
)
if
[
"
$count
"
-gt
0
]
;
then
random
=
$((
RANDOM
%
count
))
;
SPOTIFY_PLAY_URI
=
$(
\
echo
"
$results
"
|
awk
-v
random
=
"
$random
"
'/spotify:user:[a-zA-Z0-9]+:playlist:[a-zA-Z0-9]+/{i++}i==random{print; exit}'
\
)
fi
;;
"album"
|
"artist"
|
"track"
)
_args
=
${
array
[*]
:2:
$len
}
;
searchAndPlay
"
$2
"
"
$_args
"
;;
...
...
@@ -367,12 +390,12 @@ function spotify() {
else
cecho
"No results when searching for
$Q
"
;
fi
else
# play is the only param
cecho
"Playing Spotify."
;
osascript
-e
'tell application "Spotify" to play'
;
fi
break
;;
else
# play is the only param
cecho
"Playing Spotify."
;
osascript
-e
'tell application "Spotify" to play'
;
fi
break
;;
"pause"
)
state
=
$(
osascript
-e
'tell application "Spotify" to player state as string'
)
;
...
...
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