aboutsummaryrefslogtreecommitdiff
path: root/phlogthis
diff options
context:
space:
mode:
Diffstat (limited to 'phlogthis')
-rwxr-xr-xphlogthis31
1 files changed, 15 insertions, 16 deletions
diff --git a/phlogthis b/phlogthis
index b080b34..e5fc496 100755
--- a/phlogthis
+++ b/phlogthis
@@ -4,27 +4,27 @@
# requires the text formating utility 'par'
# editor is micro
-pushd "$(pwd)"
+pushd "$(pwd)" || exit
-root=$HOME/src/gopher/phlog
-remoteroot=/srv/gopher/phlog
+root="$HOME/src/gopher/phlog"
+remoteroot="/srv/gopher/phlog"
-mkdir -p $HOME/.tmp
-cd $HOME/.tmp || exit
+mkdir -p "$HOME/.tmp"
+cd "$HOME/.tmp" || exit
editfile="phlogtmp.txt"
articledate="$(date -R)"
filedate="$(date +%Y-%m-%d-%H-%I)"
article="/tmp/gophermap.tmp"
-read -r -p "Enter title: " title
+read -rp "Enter title: " title
-filetitle=$(echo $title | sed 's/ /-/g' | sed 's/[^A-Za-z0-9._-]//g')
+filetitle=$(echo "$title" | sed "s/ /-/g" | sed "s/[^A-Za-z0-9._-]//g")
dirname="$filedate-$filetitle"
# make local and remote dirs
-mkdir $root/$dirname
+mkdir "$root/$dirname"
echo "creating remote directory..."
-ssh spike mkdir $remoteroot/$dirname
+ssh spike mkdir "$remoteroot/$dirname"
# edit text
micro +4:1 "$editfile"
@@ -33,7 +33,7 @@ micro +4:1 "$editfile"
# non-empty line doesn't contain spaces
cat "$editfile" | par -jw67 > $article || cat "$editfile" > $article
-header="$title\n$articledate\n+$(printf '%*s' 65 | tr ' ' '-')+\n\n"
+header="$title\n$articledate\n+$(printf "%*s" 65 | tr " " "-")+\n\n"
sed -i "1s/^/$header/" $article
dest="$root/$dirname/gophermap"
@@ -41,23 +41,22 @@ mv "$article" "$dest"
rm $editfile
clear
-cat $dest
+cat "$dest"
echo " "
-read -p "Do you want to edit this text? : " choix1
+read -rp "Do you want to edit this text? : " choix1
if [ "$choix1" != "n" ] ; then
clear
- micro $dest
+ micro "$dest"
fi
echo "Article saved as $dest"
-read -p "Run phlogmap & phlogrss & gosend? ; " choix2
+read -rp "Run phlogmap & phlogrss & gosend? ; " choix2
if [ "$choix2" != "n" ] ; then
phlogmap; phlogrss ; gosend
fi
-popd
-exit 0
+popd || exit