Skip to content

Instantly share code, notes, and snippets.

@knowler
Last active Mar 16, 2021
Embed
What would you like to do?
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

runofthemill commented Aug 3, 2018

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