Skip to content

Instantly share code, notes, and snippets.

@acobster
Last active November 5, 2015 01:32
Show Gist options
  • Save acobster/bccf1614cb9719ff2f9f to your computer and use it in GitHub Desktop.
Save acobster/bccf1614cb9719ff2f9f to your computer and use it in GitHub Desktop.
Get to themes/plugins folders from anywhere within a WordPress Git repo
# detect the public html directory of your WP repo
wp-html-dir() {
root=$(git rev-parse --show-toplevel)
if [[ -d $root/html/wp ]] ; then
html=$root/html/wp
elif [[ -d $root/html ]] ; then
html=$root/html
elif [[ -d $root/wp ]] ; then
html=$root/wp
fi
echo $html
}
# cd wp-content/plugins from anywhere
plugins() {
cd $(wp-html-dir)/wp-content/plugins
}
# cd wp-content/plugins/$PLUGIN from anywhere, e.g.:
# $ plugin my-plugin
plugin() {
plugins && cd $1
}
# cd wp-content/themes from anywhere
themes() {
cd $(wp-html-dir)/wp-content/themes
}
# cd wp-content/themes/$PLUGIN from anywhere, e.g.:
# $ theme my-theme
theme() {
themes && cd $1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment