Last active
November 5, 2015 01:32
-
-
Save acobster/bccf1614cb9719ff2f9f to your computer and use it in GitHub Desktop.
Get to themes/plugins folders from anywhere within a WordPress Git repo
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
# 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