Expand commands

pimp looks for commands to expand in a Pimpfile. Pimpfiles are YAML files where you can define patterns to match, and what they should be matched to.

Let's say you want to show the status of your git repository whenever "git" alone is matched, this is what you would put in your Pimpfile:

# ~/.Pimpfile
git : git status -sb

You can test this with pimp git, this will execute git status -sb.

Now, what if you also want to add a custom git command? Let's say git co alone should offer you a list of branches you can checkout to. This is how you would do it;

# ~/.Pimpfile
git    : git status -sb
git co : git checkout {{GitBranches | fzf}}

Great, now what if you want to make git co point to git checkout? You can use the ... operator for that. It catches variadic arguments, and pass them along to the end of your expanded command:

# ~/.Pimpfile
git        : git status -sb
git co     : git checkout {{GitBranches | fzf}}
git co ... : git checkout

pimp git co readme.md will actually execute git checkout readme.md whereas git co will execute git checkout <branch>, with <branch> being the result of the {{GitBranches | fzf}} template being rendered.

Congratulations, you have expanded your first commands! Read more about the Command Expander to explore the full potential of command expansion with pimp. The Shell Integration section is also helpful to understand how to integrate pimp within your shell.

Next, let's see how we can use pimp as a task runner.

Last updated