From a3e3c08985176911284508085db69a3dd9cac292 Mon Sep 17 00:00:00 2001 From: PowerUser64 <blakelysnorth@gmail.com> Date: Tue, 30 Nov 2021 01:53:53 -0800 Subject: [PATCH] zsh: urlencode is optional now --- .zshrc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.zshrc b/.zshrc index bd2caab..be94123 100644 --- a/.zshrc +++ b/.zshrc @@ -320,15 +320,20 @@ # usage: sitepath # usage: sitepath <fd commands> -- you can search with 'fd' if you put in a command sitepath() { + # account for if there is no urlencode command + URLENCODE=urlencode + if ! command -v urlencode > /dev/null 2>&1;then + URLENCODE=cat + fi # If there is no input, make the input the current directory [ -z ${1+x} ] && 1="$(pwd)" FILEPATH="$(([ -e "$1" ] && readlink -f "$1") || fd $@ /home/blake/docker/blakenorth.net/site)" # change all file paths into urls echo "$FILEPATH" | - grep -o 'site.*' `# remove path to site dir` | - sed 's+^site+https://blakenorth.net+g' `# add site name` | - urlencode # if you need this, I am using dead10ck/urlencode (cargo install urlencode) + grep -o 'site.*' | + sed 's+^site+https://blakenorth.net+g' | + $URLENCODE # if you need this, I am using dead10ck/urlencode (cargo install urlencode) } # for sending error messages from functions and whatnot