From 22deab147aee1a1ae4417b25941a67ce2235076d Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Thu, 13 Jul 2017 17:17:05 +0100 Subject: [PATCH] Work on stuff --- bin/php-swap | 2 ++ config/oh-my-zsh/functions.zsh | 2 +- config/oh-my-zsh/promptconfig.zsh | 32 +++++++++++++++++++++++++------ zshrc | 3 +++ 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/bin/php-swap b/bin/php-swap index 98777849..2504f242 100755 --- a/bin/php-swap +++ b/bin/php-swap @@ -43,6 +43,8 @@ ln -s -f $phpcgi /opt/lampp/bin/php-cgi ln -s -f $phpconfig /opt/lampp/bin/php-config ln -s -f $phpize /opt/lampp/bin/phpize +# Also need to change /opt/lampp/modules/libphp7.so if 7.x. + $lampp startapache echo echo "Now on PHP ${phpexe##*-}" diff --git a/config/oh-my-zsh/functions.zsh b/config/oh-my-zsh/functions.zsh index 1947ac20..e6670dd8 100644 --- a/config/oh-my-zsh/functions.zsh +++ b/config/oh-my-zsh/functions.zsh @@ -77,7 +77,7 @@ function themes() { if [ -d $themes ]; then cdlc $themes else - echo " Can't find plugins folder " + echo " Can't find theme folder " fi else echo " Can't find public_html folder." diff --git a/config/oh-my-zsh/promptconfig.zsh b/config/oh-my-zsh/promptconfig.zsh index 50f989b0..22b15cc4 100644 --- a/config/oh-my-zsh/promptconfig.zsh +++ b/config/oh-my-zsh/promptconfig.zsh @@ -6,8 +6,11 @@ function my_dir(){ wpPluginsIcon=".p." wpThemesIcon=".t." siteIcon=" " + wpSiteIcon=" " + magentoSiteIcon=" " dropboxIcon=" " - seperator="" + seperator="  " + root=" " # Gets the path. local current_path="$(print -P "%~")" @@ -20,18 +23,35 @@ function my_dir(){ # Replace wp-content/plugins with plugin icon if in plugin # current_path=$(echo $current_path | sed -r -e "s/wp\-content\/plugins/$wpPluginsIcon/") - # If in a site folder, replace home/Sites//public_html with siteIcon - current_path=$(echo $current_path | sed -r -e "s/$homeIcon\/Sites\/([a-z_\-]*)\/public_html/$siteIcon\1/") + #This is used for checking if wp or magento + local ph=${PWD%/public_html*}/public_html + # If in a site folder and a wp site, replace home/Sites//public_html with siteIcon + if [[ -d $ph ]]; then + local icon=$siteIcon + if [[ -e "$ph/wp-config.php" ]]; then #If WordPress + icon=$wpSiteIcon + current_path=$(echo $current_path | sed -r -e "s/$homeIcon\/Sites\/([a-z_\-]*)\/public_html/$wpSiteIcon\1/") + + # Change wp-content in sub folders + current_path=$(echo $current_path | sed -r -e "s/wp\-content\//wpc\//") + + elif [[ -d "$ph/pub/opt/magento" ]]; then #If magento + icon=$magentoSiteIcon + fi + current_path=$(echo $current_path | sed -r -e "s/$homeIcon\/Sites\/([a-z_\-]*)\/public_html/$icon\1/") + fi + # Replace Dropbox with icon current_path=$(echo $current_path | sed -r -e "s/$homeIcon\/Dropbox/$dropboxIcon/") - # Change wp-content in sub folders - current_path=$(echo $current_path | sed -r -e "s/wp\-content\//wpc\//") + # Set the root + current_path=$(echo $current_path | sed -r -e "s/^\//$root/g") + # Set the seperator current_path=$(echo $current_path | sed -r -e "s/\//$seperator/g") - + echo $current_path } diff --git a/zshrc b/zshrc index a3b9b409..12a69b04 100644 --- a/zshrc +++ b/zshrc @@ -84,3 +84,6 @@ source $ZSH/oh-my-zsh.sh # Example aliases # alias zshconfig="mate ~/.zshrc" # alias ohmyzsh="mate ~/.oh-my-zsh" + +[ -r "$HOME/.smartcd_config" ] && ( [ -n $BASH_VERSION ] || [ -n $ZSH_VERSION ] ) && source ~/.smartcd_config +