genie – Run commands bound to directories
As developers, we try to automate and build shortcuts to improve our workflow. Sometimes we always run the same command in a specific project directory and then a variation of the same command in another.
A good example is when pushing code, we might run git push origin master
for one repository, but for another, we might run hub push origin,deploy master
instead. genie
helps you do that.
genie
lets you create commands that are bound to directories. In our example, we can create a push
command that, depending on which directory we run it in, invoke the correct push command.
Usage
####You can either create the command and config file semi-automatically:
-
Run:
$ genie create <command>
This will create a YAML file
~/.config/genie/<command>.yml
and the command (a softlink) in the current directory. -
Move this softlink to a directory in your $PATH so that you can run the command anywhere.
$ mv <command> /some/directory/included/in/path/
####Or, you can create them manually:
-
Figure out where
genie
is installed.$ which genie
-
Create a softlink to
genie
with a sensible name and make sure this softlink is in directory included in your $PATH. This will be your new command e.g.$ ln -s /full/path/to/genie/from/step1 <command>
-
Create a YAML configuration file matching the softlink in your user directory’s
.config/genie/
directory. e.g. For the command calledpush
, you would create~/.config/genie/push.yml
.
Configuration
Either way, update the configuration file at ~/.config/genie/<command>.yml
with commands for each directory.
Contents for the YAML file are key-value mappings from a directory path to the command to be ran in that directory (and its subdirectories):
---
/Users/hboon/code/piggyalarm: git push bb master
/Users/hboon/code/simplymeta: hub push bb,deploy master
~/code/ligify: git push bb master
You can run <command> edit
(i.e. push edit
) to open the command’s configuration file in the default editor.
Installation
gem install command-genie
License
BSD
Questions
- GitHub: genie on GitHub
- Email: hboon@motionobj.com
- Twitter: https://twitter.com/hboon