zsh: urlencode is optional now

This commit is contained in:
PowerUser64 2021-11-30 01:53:53 -08:00
parent da5a43f313
commit a3e3c08985

11
.zshrc
View file

@ -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