Last active
August 8, 2018 15:09
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Notes:
trellis/
andsite/
site/web/wp/wp-content/themes/
@dev
alias has been set up for wp-cli; see https://discourse.roots.io/t/leveraging-wp-cli-aliases-in-your-wordpress-development-workflow/8414/38?u=runofthemill for more informationThis 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 addingroots-aliases
to the plugin list in.zshrc
.