zsh: urlencode is optional now
This commit is contained in:
parent
da5a43f313
commit
a3e3c08985
1 changed files with 8 additions and 3 deletions
11
.zshrc
11
.zshrc
|
@ -320,15 +320,20 @@
|
||||||
# usage: sitepath
|
# usage: sitepath
|
||||||
# usage: sitepath <fd commands> -- you can search with 'fd' if you put in a command
|
# usage: sitepath <fd commands> -- you can search with 'fd' if you put in a command
|
||||||
sitepath() {
|
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
|
# If there is no input, make the input the current directory
|
||||||
[ -z ${1+x} ] && 1="$(pwd)"
|
[ -z ${1+x} ] && 1="$(pwd)"
|
||||||
FILEPATH="$(([ -e "$1" ] && readlink -f "$1") || fd $@ /home/blake/docker/blakenorth.net/site)"
|
FILEPATH="$(([ -e "$1" ] && readlink -f "$1") || fd $@ /home/blake/docker/blakenorth.net/site)"
|
||||||
|
|
||||||
# change all file paths into urls
|
# change all file paths into urls
|
||||||
echo "$FILEPATH" |
|
echo "$FILEPATH" |
|
||||||
grep -o 'site.*' `# remove path to site dir` |
|
grep -o 'site.*' |
|
||||||
sed 's+^site+https://blakenorth.net+g' `# add site name` |
|
sed 's+^site+https://blakenorth.net+g' |
|
||||||
urlencode # if you need this, I am using dead10ck/urlencode (cargo install urlencode)
|
$URLENCODE # if you need this, I am using dead10ck/urlencode (cargo install urlencode)
|
||||||
}
|
}
|
||||||
|
|
||||||
# for sending error messages from functions and whatnot
|
# for sending error messages from functions and whatnot
|
||||||
|
|
Loading…
Add table
Reference in a new issue