An open API service indexing awesome lists of open source software.

https://github.com/mhinz/spotlight-cli

 Command-line tool for Spotlight.
https://github.com/mhinz/spotlight-cli

macos osx shell-script spotlight

Last synced: 4 months ago
JSON representation

 Command-line tool for Spotlight.

Awesome Lists containing this project

README

          

```
$ spot
 Spotlight CLI.

If a command takes a [path], the results will be restricted to that directory.

apps Installed applications.
attr Attributes that can be used with "spot ".
author [path] Files from author.
ext [path] Any files with that extension.
$ spot ext pdf ~
file [path] Find files.
$ spot file vimrc ~/dotfiles
group [path] All files from user.
$ spot group $GID /etc
size [path] Find all files of a certain size in bytes.
Or (k)ilobytes, (m)egabytes, (g)igabytes.
$ spot size '>=' 1g ~
text [path] Find files containing text.
$ spot text 'ascii porn' ~
user [path] All files from user.
$ spot user $UID /var

Get all attributes for that path.
$ spot ~/fancy.gif
[path] Generic query. Supports any attributes from "spot attr".
See link at the bottom for the syntax.
$ spot foo
$ spot 'kMDItemMusicalGenre == *Metal*' /data/music

The Spotlight query syntax explained:
https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/SpotlightQuery/Concepts/QueryFormat.html
```

It's also fiendishly easy to add new commands to spot. For adding a command
"music", simply add an executable shell script called "spot-music" to your
$PATH:

```sh
#!/usr/bin/env bash

# The following line is optional and outputs a small reminder,
# if not enough arguments were given to the "music" command.
required $# ''

mdfind "kMDItemMusicalGenre == $1"
```

Using this, you can simply list all songs of a certain genre:

```
$ spot music Metal
$ spot music "Alpine folk music"
```

You could also change spot-music to take a second optional argument, to restrict
the matches to a certain directory:

```sh
#!/usr/bin/env bash

required $# ''

genre=$1
dir=$2

mdfind "kMDItemMusicalGenre == $genre" ${dir:+ -onlyin "$dir"}
```

Now, you can also use it like this:

```
$ spot music Metal ~/music
```