From 33cddeb978c53adfa0fea017e8c74318d3a05157 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Wed, 8 May 2019 11:19:07 +0100 Subject: [PATCH] Allows passing of a string to the theme function and will go to the first match --- shells/functions | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/shells/functions b/shells/functions index 47d9c3a0..781371b7 100644 --- a/shells/functions +++ b/shells/functions @@ -122,7 +122,11 @@ function get_theme() { wpPath=$public_html; fi domain="$(basename $(dirname $public_html ) ).local.jh" - theme=$(dirname $(wp --path="$wpPath" --url="$domain" theme path $(wp --path="$wpPath" --url="$domain" theme list 2> /dev/null | grep "active" | grep -v "inactive" | awk '{print $1}') 2> /dev/null )) + if [ ! -z "$1" ]; then + theme=$(dirname $(wp --path="$wpPath" --url="$domain" theme path $(wp --path="$wpPath" --url="$domain" theme list 2> /dev/null | grep "$1" | head -n 1 | awk '{print $1}') 2> /dev/null )) + else + theme=$(dirname $(wp --path="$wpPath" --url="$domain" theme path $(wp --path="$wpPath" --url="$domain" theme list 2> /dev/null | grep "active" | grep -v "inactive" | awk '{print $1}') 2> /dev/null )) + fi if [ -d $theme ]; then echo $theme else @@ -135,7 +139,11 @@ function get_theme() { #Takes you to the child theme function theme() { - ctheme=$(get_theme) + if [ ! -z "$1" ]; then + ctheme=$(get_theme "$1") + else + ctheme=$(get_theme) + fi if [ ! -z "$ctheme" ]; then cd $ctheme fi