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.
You can either create the command and config file semi-automatically:
$ genie create <command>
This will create a YAML file
~/.config/genie/<command>.ymland 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
$ which genie
Create a softlink to
geniewith 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 called
push, you would create
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.
gem install command-genie
- GitHub: genie on GitHub
- Email: email@example.com
Like this post? Follow me @hboon on Twitter.