Alfred Cmd

https://img.shields.io/pypi/v/alfredcmd.svg https://img.shields.io/travis/GustavoKatel/alfredcmd.svg Documentation Status

Create portable custom commands and scripts.

This is currently in beta, but usable.

Usage

All the config are located in $USER/.alfred/alfred.toml

Config

[variables]
mode="debug"

[function.branch]
exec="git rev-parse --abbrev-ref HEAD"

[command.st]
exec="git status"

[command.cc]
exec="git commit -a {@}"

[command.push]
exec="git push {@}"

[command.b]
exec="echo {branch()}"

[command.pythonCall]
exec="~/.alfred/myscript.py::myFunction"
type="python"

Run

$ alfred st
$ al cc

Variables

Variables are predefined values that can be injected in commands and functions

Example:

[variables]
mode="debug"

[command.print]
exec="echo {mode}"

Commands

Predefined commands that will be executed by Alfred

Commands are defined like this

[command.COMMAND_NAME]
exec="EXECUTION_LINE"
type="shell"
format=true
echo=false
help="HELP INFO"

Where: - COMMAND_NAME is the alias that Alfred will use to identify that command in the cli

  • EXECUTION_LINE is the code that will be called. Alfred accepts multiline entries, which

will be wrapped in a script file and executed with the default shell executor.

  • type the type of the command. Alfred currently accepts shell and python command types
  • format marks if the instance should apply the formatter in the exec line or not.

If false, the placeholders {} will not be interpreted

  • echo marks if the instance should print the command that will be executed before executing it
  • help a descriptive message that will be showed in alfred @list

Functions

Functions can be created to enhance command execution during format time and are defined like this:

[function.FUNCTION_NAME]
exec="EXECUTION_LINE"
format=true

Where:

  • FUNCTION_NAME is the alias that Alfred will use to identify that function in the formatter
  • EXECUTION_LINE is the code that will be called. Currently Alfred only accepts one-line shell commands in functions.
  • format marks if the instance should apply the formatter in the exec line or not.

If false, the placeholders {} will not be interpreted

Built-in Alfred commands

  • al[fred] @help Show help
  • al[fred] @list List all commands
  • al[fred] @version Show version

Installation

Stable release

To install Alfred, run this command in your terminal:

$ pip install alfredcmd

This is the preferred method to install Alfred, as it will always install the most recent stable release.

If you don’t have pip installed, this Python installation guide can guide you through the process.

From sources

The sources for Alfred can be downloaded from the Github repo.

You can either clone the public repository:

$ git clone git://github.com/GustavoKatel/alfredcmd

Or download the tarball:

$ curl  -OL https://github.com/GustavoKatel/alfredcmd/tarball/master

Once you have a copy of the source, you can install it with:

$ python setup.py install

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.