Skip to content

Instantly share code, notes, and snippets.

@runofthemill
Last active August 8, 2018 15:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save runofthemill/bbbb3a826fe9e08fff4262ae3b2d6c7d to your computer and use it in GitHub Desktop.
Save runofthemill/bbbb3a826fe9e08fff4262ae3b2d6c7d to your computer and use it in GitHub Desktop.
Aliases for navigating a Roots project in a local environment. Inspired by https://gist.github.com/knowler/7c0686c4c1876980657f369213287749
root() {
local root
if [[ "$PWD" == *"/trellis"* ]]; then
root=${PWD%/trellis*}
elif [[ "$PWD" == *"/site"* ]]; then
root=${PWD%/site*}
elif [[ -d "$PWD/trellis" || -d "$PWD/site" ]]; then
root=${PWD}
fi
echo "$root"
}
alias theme='cd $(root)/site/web/app/themes/$(wp @dev option get stylesheet | cut -d/ -f1)'
alias trellis='cd $(root)/trellis'
alias site='cd $(root)/site'
@runofthemill
Copy link
Author

runofthemill commented Aug 3, 2018

Notes:

This can be used as a standalone script, or as a custom Oh-My-Zsh plugin by creating a folder named roots-aliases in the ZSH custom folder (defaults to $ZSH/custom) and placing this file within, then adding roots-aliases to the plugin list in .zshrc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment