Skip to content

Instantly share code, notes, and snippets.

@knowler
Last active March 16, 2021 17:23
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knowler/7c0686c4c1876980657f369213287749 to your computer and use it in GitHub Desktop.
Save knowler/7c0686c4c1876980657f369213287749 to your computer and use it in GitHub Desktop.
theme() { cd $(wp theme path)/$(wp option get stylesheet | cut -d/ -f1) }
@knowler
Copy link
Author

knowler commented May 17, 2018

cut -d/ -f1

This is for themes like Sage, which are one level deep.

@runofthemill
Copy link

I got inspired and made a version for local dev with aliases for getting to the trellis/ and site/ folders as well - https://gist.github.com/runofthemill/bbbb3a826fe9e08fff4262ae3b2d6c7d

@knowler
Copy link
Author

knowler commented Aug 8, 2018

Awesome @runofthemill! I have one for Bedrock/normal WordPress that also functions as a shortcut to that directory, but also a quick way to install/activate plugins from Packagist and WPackagist. These are from my old dotfiles that haven't ported over yet.

bedrock() {
  startDir="$(pwd)"
  sitePath="$(dirname `dirname $(wp config path)`)"

  cd $sitePath

  if [ -z "$1" ]; then
    return false
  elif [ $# -eq 2 ]; then
    composer require $1/${2} && wp plugin activate ${2}
    cd $startDir
  else
    composer require wpackagist-plugin/$1 && wp plugin activate $1
    cd $startDir
  fi

} 

bedrock-dev() {
  startDir="$(pwd)"
  sitePath="$(dirname `dirname $(wp config path)`)"

  cd $sitePath

  if [ $# -eq 2 ]; then
    composer require --dev $1/${2} && wp plugin activate ${2}
  else
    composer require --dev wpackagist-plugin/$1 && wp plugin activate $1
  fi

  cd $startDir
}

wpp() {
  startDir="$(pwd)"
  sitePath="$(dirname `wp config path`)"

  cd $sitePath

  if [ -z "$1" ]; then
    return false
  elif [ $# -eq 2 ]; then
    composer require $1/${2} && wp plugin activate ${2}
    cd $startDir
  else
    composer require wpackagist-plugin/$1 && wp plugin activate $1
    cd $startDir
  fi
} 

wpp-dev() {
  startDir="$(pwd)"
  sitePath="$(dirname `wp config path`)"

  cd $sitePath

  if [ -z "$1" ]; then
    return false
  elif [ $# -eq 2 ]; then
    composer require --dev $1/${2} && wp plugin activate ${2}
    cd $startDir
  else
    composer require --dev wpackagist-plugin/$1 && wp plugin activate $1
    cd $startDir
  fi
} 

I've been using these to jump around lately:
https://github.com/knowler/dotfiles/blob/48c2413cc81926b640edc87438557a55ee70b85c/scripts/git.sh#L7-L23

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