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
3b2f827d
Commit
3b2f827d
authored
Aug 30, 2016
by
mahi97
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add Search Option for album,artist and tracks
parent
96d57dc3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
1 deletion
+41
-1
osx.plugin.zsh
plugins/osx/osx.plugin.zsh
+41
-1
No files found.
plugins/osx/osx.plugin.zsh
View file @
3b2f827d
...
...
@@ -330,9 +330,49 @@ function spotify() {
case
$arg
in
"play"
)
if
[
$#
!=
1
]
;
then
# There are additional arguments, so find out how many
array
=(
$@
)
;
len
=
${#
array
[@]
}
;
SPOTIFY_SEARCH_API
=
"https://api.spotify.com/v1/search"
SPOTIFY_PLAY_URI
=
""
;
searchAndPlay
()
{
type
=
"
$1
"
Q
=
"
$2
"
cecho
"Searching
${
type
}
s for:
$Q
"
;
SPOTIFY_PLAY_URI
=
$(
\
curl
-s
-G
$SPOTIFY_SEARCH_API
--data-urlencode
"q=
$Q
"
-d
"type=
$type
&limit=1&offset=0"
-H
"Accept: application/json"
\
|
grep
-E
-o
"spotify:
$type
:[a-zA-Z0-9]+"
-m
1
)
}
case
$2
in
"album"
|
"artist"
|
"track"
)
_args
=
${
array
[*]
:2:
$len
}
;
searchAndPlay
"
$2
"
"
$_args
"
;;
*
)
_args
=
${
array
[*]
:1:
$len
}
;
searchAndPlay track
"
$_args
"
;;
esac
if
[
"
$SPOTIFY_PLAY_URI
"
!=
""
]
;
then
cecho
"Playing (
$Q
Search) -> Spotify URL: $"
;
osascript
-e
"tell application
\"
Spotify
\"
to play track
\"
$SPOTIFY_PLAY_URI
\"
"
;
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'
;
break
;;
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