lb

Script that generates my blog system and RSS feed
Log | Files | Refs | README | LICENSE

commit f13cf1a3a642dcaa6eb188b15db4e36450edcabd
parent 126c70f4d277e87e99bbbfb7e0fcf20c4a5780f6
Author: Luke Smith <luke@lukesmith.xyz>
Date:   Wed,  8 Jul 2020 11:22:43 -0400

Merge pull request #25 from chrissxYT/patch-2

Improved listAndReturn()
Diffstat:
Mlb | 16+++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/lb b/lb @@ -27,11 +27,17 @@ newpost() { read -erp "Give a title for your post: [ -f "$webdir/blog/$url.html" ] && echo "There is already an existing published entry of that same name/URL." && exit $EDITOR "$webdir/blog/.drafts/$url.html" ;} -listandReturn() { printf "Listing contents of %s.\\n" "$1" - ls -rc "$1" | awk -F '/' '{print $NF}' | nl - read -erp "Pick an entry by number to $2, or press ctrl-c to cancel. " number - chosen="$(ls -rc "$1" | nl | grep -w "$number" | awk '{print $2}')" - basefile="$(basename "$chosen")" && base="${basefile%.*}" ;} +listandReturn() { + filecount=$(ls "$1" | wc -l) + [ $filecount -eq 0 ] && echo "There's nothing to $2." && exit 1 + number=1 + [ $filecount -eq 1 ] || { + ls -rc "$1" | awk -F '/' '{print $NF}' | nl + read -erp "Pick an entry by number to $2, or press Ctrl-C to cancel. " number + } + chosen="$(ls -rc "$1" | nl | grep -w "$number" | awk '{print $2}')" + basefile="$(basename "$chosen")" && base="${basefile%.*}" +} publish() { \ delete