Skip to content
jasoncodes edited this page Mar 20, 2013 · 12 revisions

Filters allow you to run specified files through arbitrary commands at build time.

Examples

ERB

Setting name and email with environment variables in gitconfig.erb.

# ~/.freshrc
fresh config/gitconfig.erb --file=~/.gitconfig --filter=erb
# ~/.dotfiles/config/gitconfig.erb
[user]
name=<%= ENV["NAME"] %>
email=<%= ENV["EMAIL"] %>

GnuPG

Decrypting files with GnuPG.

# ~/.freshrc
fresh encrypted_file.asc --filter=gpg

Replacing content in a sourced file with sed

You can use sed to apply a regular expression replacement to source file. Here’s an example to replace a placeholder username with your actual username:

# ~/.freshrc
fresh gitconfig --file --filter="sed 's/_USER_/$USER/g'"

Sourcing part of a file with sed

You can use sed to grab parts of a file. Here is an example of getting rbenv initialization lines. We've also locked the file to a certain git ref in case the line numbers change.

# ~/.freshrc
fresh jasoncodes/dotfiles shell/profile --ref=452fb01 --filter='sed -n 224,227p'
Clone this wiki locally