Skip to content

Scripting your freshrc file

Odin Dutton edited this page Aug 19, 2013 · 6 revisions

You can use all your usual shell programming constructs in your .freshrc allowing you to do things like the below.

Conditionally include based on operating system or hostname

if [[ "$(uname)" == "Darwin" ]]; then
  fresh systems/darwin.sh
fi
if [[ "$(hostname -s)" == "myhost" ]]; then
  fresh systems/myhost.sh
fi

Merge in host specific configuration

e.g. You might want your git user.name and user.email to be set differently at work and at home.

fresh-options --file=~/.gitconfig
  fresh git/gitconfig.$(hostname -s)
  fresh git/gitconfig
fresh-options

Use loops to generate multiple fresh lines

for REPO in tpope/vim-{pathogen,liquid,rsi}; do
  fresh $REPO . --file=~/.vim/bundle/$(basename $REPO)/
done

Ignoring missing files

You may wish to silently ignore missing files when scripting your freshrc. You can use the --ignore-missing to do so.

fresh zsh/$PROFILE --file=~/.zshrc --ignore-missing