Giter Club home page Giter Club logo

spotlight-cli's Introduction

$ 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 <query>".
author <query> [path]     Files from author.
ext <query> [path]        Any files with that extension.
                          $ spot ext pdf ~
file <query> [path]       Find files.
                          $ spot file vimrc ~/dotfiles
group <group|gid> [path]  All files from user.
                          $ spot group $GID /etc
size <rel> <size> [path]  Find all files of a certain size in bytes.
                          Or (k)ilobytes, (m)egabytes, (g)igabytes.
                          $ spot size '>=' 1g ~
text <query> [path]       Find files containing text.
                          $ spot text 'ascii porn' ~
user <user|uid> [path]    All files from user.
                          $ spot user $UID /var

<path>                    Get all attributes for that path.
                          $ spot ~/fancy.gif
<query> [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:

#!/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 $# '<genre>'

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:

#!/usr/bin/env bash

required $# '<genre>'

genre=$1
dir=$2

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

Now, you can also use it like this:

$ spot music Metal ~/music

spotlight-cli's People

Contributors

mhinz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

spotlight-cli's Issues

Thanks!

Just what the mac cli needed. Appreciate you making it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.