From db52ff488e98543c821b42488d01bb8c05333158 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Thu, 4 Oct 2018 16:49:00 +0100 Subject: [PATCH 1/5] Add bitbucket dotjs script --- config/dotjs/bitbucket.org.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 config/dotjs/bitbucket.org.js diff --git a/config/dotjs/bitbucket.org.js b/config/dotjs/bitbucket.org.js new file mode 100644 index 00000000..382bb409 --- /dev/null +++ b/config/dotjs/bitbucket.org.js @@ -0,0 +1,23 @@ +((() => { + const domLoaded = function domLoaded(){ + document.removeEventListener("readystatechange",domLoaded); + document.querySelectorAll("li").forEach(li => { + console.log(li); + if( li.innerHTML.indexOf( '[' ) !== -1 ){ + li.innerHTML = li.innerHTML.replace(/\[ \]/g, '☐'); + li.innerHTML = li.innerHTML.replace(/\[x\]/g, '☒'); + } + } ); + } + + console.log("I get here"); + if(document.readyState == "loading"){ + + //If the dom hasn't loaded, wait until it is + document.addEventListener("readystatechange",domLoaded); + return; + } else { + //If it has, run the domLoaded function + domLoaded(); + } +}))(); From 5effc743b7bf0b196d04704b43b589668485cd33 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Thu, 4 Oct 2018 16:49:39 +0100 Subject: [PATCH 2/5] Make dotjs work with .local.jh --- chromeExtentions/dotjs/dotjs.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/chromeExtentions/dotjs/dotjs.js b/chromeExtentions/dotjs/dotjs.js index a1a24423..0de96e13 100644 --- a/chromeExtentions/dotjs/dotjs.js +++ b/chromeExtentions/dotjs/dotjs.js @@ -1,6 +1,8 @@ -if(window.location.host.indexOf(".local") != -1){ +console.log( "yay" ); +if(window.location.host.indexOf(".local.jh") == -1){ +console.log( "I get here" ); var xhr = new XMLHttpRequest(); - xhr.open('GET', 'https://dotjs.local/' + window.location.host.replace(/^www\./, '') + '.js'); + xhr.open('GET', 'https://dotjs.local.jh/' + window.location.host.replace(/^www\./, '') + '.js'); xhr.onreadystatechange = function() { if(xhr.readyState == 4) { @@ -11,7 +13,7 @@ if(window.location.host.indexOf(".local") != -1){ return; } else if(xhr.status == 404) { var defaultXHR = new XMLHttpRequest(); - defaultXHR.open('GET', 'https://dotjs.local/default.js'); + defaultXHR.open('GET', 'https://dotjs.local.jh/default.js'); defaultXHR.onreadystatechange = function() { if (defaultXHR.readyState == 4 && defaultXHR.status == 200){ var script = document.createElement('script'); From 9bba0b14c61b610fd5e5bd6762c63dec27e90a05 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Thu, 4 Oct 2018 16:50:04 +0100 Subject: [PATCH 3/5] Make i3 work with new version of i3-blocks --- i3/blocks/bandwidth | 107 ++++++++++++++++++++++++++++++++++++ i3/blocks/brightness | 4 +- i3/blocks/cpu | 60 ++++++++++++++++++++ i3/blocks/freeSpace | 4 +- i3/blocks/homeServerUpdates | 4 +- i3/blocks/mediaplayer | 3 +- i3/blocks/pacmanUpdates | 9 ++- i3/blocks/volume | 83 ++++++++++++++++++++++++++++ i3/i3blocks-secondary.conf | 23 ++++++-- i3/i3blocks.conf | 9 ++- 10 files changed, 288 insertions(+), 18 deletions(-) create mode 100755 i3/blocks/bandwidth create mode 100755 i3/blocks/cpu create mode 100755 i3/blocks/volume diff --git a/i3/blocks/bandwidth b/i3/blocks/bandwidth new file mode 100755 index 00000000..1259366b --- /dev/null +++ b/i3/blocks/bandwidth @@ -0,0 +1,107 @@ +#!/bin/bash +# Copyright (C) 2012 Stefan Breunig +# Copyright (C) 2014 kaueraal +# Copyright (C) 2015 Thiago Perrotta + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Get custom IN and OUT labels if provided by command line arguments +while [[ $# -gt 1 ]]; do + key="$1" + case "$key" in + -i|--inlabel) + INLABEL="$2" + shift;; + -o|--outlabel) + OUTLABEL="$2" + shift;; + esac + shift +done + +[[ -z $INLABEL ]] && INLABEL="IN " +[[ -z $OUTLABEL ]] && OUTLABEL="OUT " + +# Use the provided interface, otherwise the device used for the default route. +if [[ -z $INTERFACE ]] && [[ -n $BLOCK_INSTANCE ]]; then + INTERFACE=$BLOCK_INSTANCE +elif [[ -z $INTERFACE ]]; then + INTERFACE=$(ip route | awk '/^default/ { print $5 ; exit }') +fi + +# Issue #36 compliant. +if ! [ -e "/sys/class/net/${INTERFACE}/operstate" ] || ! [ "`cat /sys/class/net/${INTERFACE}/operstate`" = "up" ] +then + echo "$INTERFACE down" + echo "$INTERFACE down" + echo "#FF0000" + exit 0 +fi + +# path to store the old results in +path="/dev/shm/$(basename $0)-${INTERFACE}" + +# grabbing data for each adapter. +read rx < "/sys/class/net/${INTERFACE}/statistics/rx_bytes" +read tx < "/sys/class/net/${INTERFACE}/statistics/tx_bytes" + +# get time +time=$(date +%s) + +# write current data if file does not exist. Do not exit, this will cause +# problems if this file is sourced instead of executed as another process. +if ! [[ -f "${path}" ]]; then + echo "${time} ${rx} ${tx}" > "${path}" + chmod 0666 "${path}" +fi + +# read previous state and update data storage +read old < "${path}" +echo "${time} ${rx} ${tx}" > "${path}" + +# parse old data and calc time passed +old=(${old//;/ }) +time_diff=$(( $time - ${old[0]} )) + +# sanity check: has a positive amount of time passed +[[ "${time_diff}" -gt 0 ]] || exit + +# calc bytes transferred, and their rate in byte/s +rx_diff=$(( $rx - ${old[1]} )) +tx_diff=$(( $tx - ${old[2]} )) +rx_rate=$(( $rx_diff / $time_diff )) +tx_rate=$(( $tx_diff / $time_diff )) + +# shift by 10 bytes to get KiB/s. If the value is larger than +# 1024^2 = 1048576, then display MiB/s instead + +# incoming +echo -n "$INLABEL" +rx_kib=$(( $rx_rate >> 10 )) +if hash bc 2>/dev/null && [[ "$rx_rate" -gt 1048576 ]]; then + printf '%sM' "`echo "scale=1; $rx_kib / 1024" | bc`" +else + echo -n "${rx_kib}K" +fi + +echo -n " " + +# outgoing +echo -n "$OUTLABEL" +tx_kib=$(( $tx_rate >> 10 )) +if hash bc 2>/dev/null && [[ "$tx_rate" -gt 1048576 ]]; then + printf '%sM' "`echo "scale=1; $tx_kib / 1024" | bc`" +else + echo -n "${tx_kib}K" +fi diff --git a/i3/blocks/brightness b/i3/blocks/brightness index 7761b65f..5737a544 100755 --- a/i3/blocks/brightness +++ b/i3/blocks/brightness @@ -48,8 +48,8 @@ if [[ "${percent}" -le 0 ]]; then exit fi -echo "🔆${percent}%" -echo "${percent}%" +echo "${label} ${percent}%" +echo "${label} ${percent}%" echo "" if [[ "${percent}" -le "${URGENT_VALUE}" ]]; then diff --git a/i3/blocks/cpu b/i3/blocks/cpu new file mode 100755 index 00000000..55b6f5d5 --- /dev/null +++ b/i3/blocks/cpu @@ -0,0 +1,60 @@ +#!/usr/bin/perl +# +# Copyright 2014 Pierre Mavro +# Copyright 2014 Vivien Didelot +# Copyright 2014 Andreas Guldstrand +# +# Licensed under the terms of the GNU GPL v3, or any later version. + +use strict; +use warnings; +use utf8; +use Getopt::Long; + +# default values +my $t_warn = $ENV{T_WARN} || 50; +my $t_crit = $ENV{T_CRIT} || 80; +my $cpu_usage = -1; +my $decimals = $ENV{DECIMALS} || 2; +my $label = $ENV{label} || ""; + +sub help { + print "Usage: cpu_usage [-w ] [-c ] [-d ]\n"; + print "-w : warning threshold to become yellow\n"; + print "-c : critical threshold to become red\n"; + print "-d : Use decimals for percentage (default is $decimals) \n"; + exit 0; +} + +GetOptions("help|h" => \&help, + "w=i" => \$t_warn, + "c=i" => \$t_crit, + "d=i" => \$decimals, +); + +# Get CPU usage +$ENV{LC_ALL}="en_US"; # if mpstat is not run under en_US locale, things may break, so make sure it is +open (MPSTAT, 'mpstat 1 1 |') or die; +while () { + if (/^.*\s+(\d+\.\d+)[\s\x00]?$/) { + $cpu_usage = 100 - $1; # 100% - %idle + last; + } +} +close(MPSTAT); + +$cpu_usage eq -1 and die 'Can\'t find CPU information'; + +# Print short_text, full_text +printf "${label} %.${decimals}f%%\n", $cpu_usage; +printf "${label} %.${decimals}f%%\n", $cpu_usage; + +# Print color, if needed +if ($cpu_usage >= $t_crit) { + print "#FF0000\n"; + exit 33; +} elsif ($cpu_usage >= $t_warn) { + print "#FFFC00\n"; +} + +exit 0; diff --git a/i3/blocks/freeSpace b/i3/blocks/freeSpace index 91060e05..10647ec7 100755 --- a/i3/blocks/freeSpace +++ b/i3/blocks/freeSpace @@ -18,8 +18,8 @@ if [ "$BLOCK_BUTTON" = "1" ]; then echo "$used/$total" echo "$used/$total" else - echo "$percent%" - echo "$percent%" + echo "$label $percent%" + echo "$label $percent%" fi diff --git a/i3/blocks/homeServerUpdates b/i3/blocks/homeServerUpdates index b057289c..15d515fd 100755 --- a/i3/blocks/homeServerUpdates +++ b/i3/blocks/homeServerUpdates @@ -4,8 +4,8 @@ count=$(ssh homeServer -t checkupdates | wc -l) if [ "$count" = "0" ]; then echo "" else - echo $count - echo $count + echo "$label $count" + echo "$label $count" if [ "$count" -gt "5" ]; then echo "#FFOOOO" else diff --git a/i3/blocks/mediaplayer b/i3/blocks/mediaplayer index 2dfc80ba..e87a17b3 100755 --- a/i3/blocks/mediaplayer +++ b/i3/blocks/mediaplayer @@ -1,7 +1,8 @@ #!/usr/bin/sh -COMMAND="playerctl --player=$BLOCK_INSTANCE" +#COMMAND="playerctl --player=$BLOCK_INSTANCE" +COMMAND="playerctl" case $BLOCK_BUTTON in 1) $COMMAND previous ;; diff --git a/i3/blocks/pacmanUpdates b/i3/blocks/pacmanUpdates index fdfdb343..29d7526e 100755 --- a/i3/blocks/pacmanUpdates +++ b/i3/blocks/pacmanUpdates @@ -7,10 +7,13 @@ if ! command -v checkupdates > /dev/null; then else count=$(checkupdates | wc -l) if [ "$count" = "0" ]; then - count="" + echo "" + echo "" + echo "" + exit 0 fi - echo $count - echo $count + echo "$label $count" + echo "$label $count" if [ "$count" -gt "5" ]; then echo "#FFOOOO" else diff --git a/i3/blocks/volume b/i3/blocks/volume new file mode 100755 index 00000000..82712500 --- /dev/null +++ b/i3/blocks/volume @@ -0,0 +1,83 @@ +#!/bin/bash +# Copyright (C) 2014 Julien Bonjean +# Copyright (C) 2014 Alexander Keller + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +#------------------------------------------------------------------------ + +# The second parameter overrides the mixer selection +# For PulseAudio users, eventually use "pulse" +# For Jack/Jack2 users, use "jackplug" +# For ALSA users, you may use "default" for your primary card +# or you may use hw:# where # is the number of the card desired +if [[ -z "$MIXER" ]] ; then + MIXER="default" + if command -v pulseaudio >/dev/null 2>&1 && pulseaudio --check ; then + # pulseaudio is running, but not all installations use "pulse" + if amixer -D pulse info >/dev/null 2>&1 ; then + MIXER="pulse" + fi + fi + [ -n "$(lsmod | grep jack)" ] && MIXER="jackplug" + MIXER="${2:-$MIXER}" +fi + +# The instance option sets the control to report and configure +# This defaults to the first control of your selected mixer +# For a list of the available, use `amixer -D $Your_Mixer scontrols` +if [[ -z "$SCONTROL" ]] ; then + SCONTROL="${BLOCK_INSTANCE:-$(amixer -D $MIXER scontrols | + sed -n "s/Simple mixer control '\([^']*\)',0/\1/p" | + head -n1 + )}" +fi + +# The first parameter sets the step to change the volume by (and units to display) +# This may be in in % or dB (eg. 5% or 3dB) +if [[ -z "$STEP" ]] ; then + STEP="${1:-5%}" +fi + +#------------------------------------------------------------------------ + +capability() { # Return "Capture" if the device is a capture device + amixer -D $MIXER get $SCONTROL | + sed -n "s/ Capabilities:.*cvolume.*/Capture/p" +} + +volume() { + amixer -D $MIXER get $SCONTROL $(capability) +} + +format() { + perl_filter='if (/.*\[(\d+%)\] (\[(-?\d+.\d+dB)\] )?\[(on|off)\]/)' + perl_filter+='{CORE::say $4 eq "off" ? "MUTE" : "' + # If dB was selected, print that instead + perl_filter+=$([[ $STEP = *dB ]] && echo "$label "'$3' || echo "$label "'$1') + perl_filter+='"; exit}' + perl -ne "$perl_filter" + #tmp=$(perl -ne "$perl_filter") + #echo "$label $tmp" +} + +#------------------------------------------------------------------------ + +case $BLOCK_BUTTON in + 3) amixer -q -D $MIXER sset $SCONTROL $(capability) toggle ;; # right click, mute/unmute + 4) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}+ unmute ;; # scroll up, increase + 5) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}- unmute ;; # scroll down, decrease +esac + +volume | format diff --git a/i3/i3blocks-secondary.conf b/i3/i3blocks-secondary.conf index 99cf9ca8..187503de 100644 --- a/i3/i3blocks-secondary.conf +++ b/i3/i3blocks-secondary.conf @@ -42,12 +42,19 @@ command=xset -q | grep Caps 2> /dev/null | cut -c23 | sed "s/n/CAPS/" | sed "s/f signal=11 color=#00FF00 + #[nameservers] #interval=5 -#command=~/.dotfiles/i3/blocks/nameservers domain.com -#label=Example Nameservers +#command=~/.dotfiles/i3/blocks/dns storedev.checkit.net a 185.181.126.141 +#label=storedev.checkit.net +#separator=false # -#[siteStatis] +#[anameserver] +#interval=5 +#command=drill a example.com @ns.mainnameserver.com | sed -ne '/ANSWER SECTION/,/AUTHORITY SECTION/ p' | head -n -2 | tail -n +2 | awk '{ print $5" " }' | xargs echo + + +#[siteStatus] #interval=5 #command=~/.dotfiles/i3/blocks/siteStatus https://www.domain.com "Something that should be found on a working request" @@ -85,13 +92,17 @@ separator=false [vapourtecstatus] command=~/.dotfiles/i3/blocks/serverStatus Vapourtec interval=30 +separator=false + +[checkitstatus] +command=~/.dotfiles/i3/blocks/serverStatus Checkit +interval=30 [wanip] label=🌍 -command=echo " $(curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//') " +command=echo "$label $(curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//')" interval=30 -markup=pango -#colorI#= +color=#00FF00 # Date Time diff --git a/i3/i3blocks.conf b/i3/i3blocks.conf index bfa599ec..d9d49102 100644 --- a/i3/i3blocks.conf +++ b/i3/i3blocks.conf @@ -76,6 +76,7 @@ markup=pango [volume] #label=VOL label=🔊 +command=~/.dotfiles/i3/blocks/volume instance=Master #instance=PCM interval=once @@ -125,8 +126,11 @@ interval=10 separator=false [bandwidth] -command=/usr/lib/i3blocks/$BLOCK_NAME | sed "s/IN/↓/g" | sed "s/OUT/↑/g" -#instance=eth0 +command=~/.dotfiles/i3/blocks/bandwidth +#command=/usr/lib/i3blocks/$BLOCK_NAME | sed "s/IN/↓/g" | sed "s/OUT/↑/g" +#instance=eno1 +#INLABEL=↓ +#OUTLABEL=↑ interval=2 # CPU usage @@ -136,6 +140,7 @@ interval=2 [cpu_usage] label=CPU interval=10 +command=~/.dotfiles/i3/blocks/cpu #min_width=CPU: 100.00% #separator=false From 0bf69b5bb1200db33e1004e5aa74c17489944dc6 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Thu, 4 Oct 2018 16:50:43 +0100 Subject: [PATCH 4/5] Add scripts for managing images --- bin/imageResizeFolder | 27 +++++++++++++++++++++++++++ bin/lanPortImages | 22 ++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100755 bin/imageResizeFolder create mode 100755 bin/lanPortImages diff --git a/bin/imageResizeFolder b/bin/imageResizeFolder new file mode 100755 index 00000000..ab000814 --- /dev/null +++ b/bin/imageResizeFolder @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# Purpose: batch image resizer + +# absolute path to image folder +FOLDER="$PWD" + +# max height +WIDTH=${1:-"999999"} + +# max width +HEIGHT=${2:-"999999"} + +echo "Width: $WIDTH"; +echo "Height: $HEIGHT"; + +#resize png or jpg to either height or width, keeps proportions using imagemagick +#find ${PWD} -iname '*.jpg' -o -iname '*.png' -exec echo convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{}.new.jpg \; +find ${PWD} \( -iname "*.jpg" -o -iname "*.png" \) -exec convert {} -verbose -resize "$WIDTH"x"$HEIGHT" \{}.new \; + +#resize png to either height or width, keeps proportions using imagemagick +#find ${FOLDER} -iname '*.png' -exec convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{} \; + +#resize jpg only to either height or width, keeps proportions using imagemagick +#find ${FOLDER} -iname '*.jpg' -exec convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{} \; + +# alternative +#mogrify -path ${FOLDER} -resize ${WIDTH}x${HEIGHT}% *.png -verbose diff --git a/bin/lanPortImages b/bin/lanPortImages new file mode 100755 index 00000000..81c8181b --- /dev/null +++ b/bin/lanPortImages @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +mkdir "portraits" +mkdir "landscapes" +for f in ./*.jpg; do + WIDTH=$(identify -format "%w" "$f")> /dev/null + HEIGHT=$(identify -format "%h" "$f")> /dev/null + echo "Width: $WIDTH" + echo "Height: $HEIGHT" + echo "" + if [[ "$HEIGHT" > "$WIDTH" ]]; then + mv "$f" portraits/ + else + mv "$f" landscapes/ + fi + #if file "$f" 2>&1 | awk '/w =/{w=$5+0; h=$7+0; if (h>w) exit; else exit 1}' + #then + # mv "$f" portraits/ + #else + # mv "$f" landscapes/ + #fi +done From de90f690afadc83af254bf60f1c4c90a781f60a9 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Thu, 4 Oct 2018 16:51:25 +0100 Subject: [PATCH 5/5] Update zsh config --- shells/functions | 85 ++++++++++++++++-------------- shells/zsh/oh-my-zsh/shortcuts.zsh | 13 +++++ 2 files changed, 59 insertions(+), 39 deletions(-) create mode 100644 shells/zsh/oh-my-zsh/shortcuts.zsh diff --git a/shells/functions b/shells/functions index 2a6879c8..05d51285 100644 --- a/shells/functions +++ b/shells/functions @@ -112,8 +112,7 @@ function ptheme() { fi } -#Takes you to the child theme -function theme() { +function get_theme() { public_html=${PWD%/public_html*}/public_html if [ -d $public_html ]; then if [ -d $public_html/wp ]; then @@ -123,42 +122,41 @@ function theme() { fi theme=$(dirname $(wp --path="$wpPath" theme path $(wp --path="$wpPath" theme list | grep "active" | grep -v "inactive" | awk '{print $1}'))) if [ -d $theme ]; then - cd $theme + echo $theme else - echo " Can't find theme folder " + echo "" fi else - echo " Can't find public_html folder." + echo "" + fi +} + +#Takes you to the child theme +function theme() { + ctheme=$(get_theme) + if [ ! -z "$ctheme" ]; then + cd $ctheme fi } #Takes you to the js folder child theme function js() { - public_html=${PWD%/public_html*}/public_html - if [ -d $public_html ]; then - if [ -d $public_html/wp ]; then - wpPath=$public_html/wp; - else - wpPath=$public_html; - fi - theme=$(dirname $(wp --path="$wpPath" theme path $(wp --path="$wpPath" theme list | grep "active" | grep -v "inactive" | awk '{print $1}'))) - if [ -d $theme ]; then - if [ -d "$theme/js" ]; then - cd "$theme/js" - else - echo "Can't find a JS folder. Here is the theme" - cd "$theme" - fi - else - echo " Can't find theme folder " - fi - else - echo " Can't find public_html folder." + ctheme=$(get_theme) + if [ ! -z "$ctheme" ]; then + cd $ctheme/js fi } #Takes you to the css folder child theme function css() { + ctheme=$(get_theme) + if [ ! -z "$ctheme" ]; then + cd $ctheme/css + fi +} + +#Takes you to the plugin directory +function plugins() { public_html=${PWD%/public_html*}/public_html if [ -d $public_html ]; then if [ -d $public_html/wp ]; then @@ -166,24 +164,14 @@ function css() { else wpPath=$public_html; fi - theme=$(dirname $(wp --path="$wpPath" theme path $(wp --path="$wpPath" theme list | grep "active" | grep -v "inactive" | awk '{print $1}'))) - if [ -d $theme ]; then - if [ -d "$theme/css" ]; then - cd "$theme/css" - else - echo "Can't find a CSS folder. Here is the theme" - cd "$theme" - fi - else - echo " Can't find theme folder " - fi + cd $(wp --path="$wpPath" plugin path) else echo " Can't find public_html folder." fi } -#Takes you to the plugin directory -function plugins() { +#Copies a woo tepmplate file to the theme +function woocp() { public_html=${PWD%/public_html*}/public_html if [ -d $public_html ]; then if [ -d $public_html/wp ]; then @@ -191,7 +179,26 @@ function plugins() { else wpPath=$public_html; fi - cd $(wp --path="$wpPath" plugin path) + woocommerce=$(dirname $(wp --path="$wpPath" plugin path woocommerce)) + themes=$(dirname $(wp --path="$wpPath" theme path )) + if [ -d "$woocommerce" ]; then + #If we are here, we know what the woocommerce path is. + # If in WOO directory, we want to copy to the theme directory. If we are not in Woo directory, copy to the current directory + case $PWD/ in + $woocommerce/*) + theme=$(get_theme) + #if [[ $PWD = $woocommerce/templates + ;; + $themes/*) + echo "in themes dir" + ;; + *) + echo "soewhere else" + ;; + esac + else + echo "Can't find woocommerce" + fi; else echo " Can't find public_html folder." fi diff --git a/shells/zsh/oh-my-zsh/shortcuts.zsh b/shells/zsh/oh-my-zsh/shortcuts.zsh new file mode 100644 index 00000000..ff8d5649 --- /dev/null +++ b/shells/zsh/oh-my-zsh/shortcuts.zsh @@ -0,0 +1,13 @@ +#!/usr/bin/env zsh + +function append_date() { + # Prepend "info" to the command line and run it. + BUFFER="$BUFFER-$(date '+%Y-%m-%d')" + zle end-of-line +} + +# Define a widget called "run_info", mapped to our function above. +zle -N append_date + +# Bind it to ESC-i. +bindkey "" append_date