zsh: almost all functions are scripts now (part 2)
This commit is contained in:
parent
75c3986785
commit
ec0cee28d9
14 changed files with 287 additions and 0 deletions
23
.config/shell/bin/sitepath
Executable file
23
.config/shell/bin/sitepath
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
# TODO: encode the url to fix things like spaces using something like https://stackoverflow.com/a/10660730/11162605
|
||||
# usage: sitepath <path to file>
|
||||
# usage: sitepath <file to find>
|
||||
# usage: sitepath
|
||||
# usage: sitepath <fd commands> -- you can search with 'fd' if you put in a command
|
||||
|
||||
# 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.*' |
|
||||
sed 's+^site+https://blakenorth.net+g' |
|
||||
$URLENCODE # if you need this, I am using dead10ck/urlencode (cargo install urlencode)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue