dotfiles/stow_home/rofi/.config/rofi/scripts/qpost.sh

35 lines
1.4 KiB
Bash
Executable File

#! /bin/bash
path=$HOME/git/joelchrono12.ml/_posts/
title=$(rofi -l 0 -width 50 -p "Title" -dmenu)
filen=$(echo $title | tr " ,.!" "-"| awk '{print tolower($0)}')
if [ -z $title ]; then
exit
fi
today=$(date +"%Y-%m-%d")
filename=($today-$filen)
description=$(rofi -l 0 -width 60 -height 20 -p "Description" -dmenu)
tags=$(rofi -l 0 -width 45 -p "Tags" -dmenu)
num=0
while [ $num = 0 ]; do
choice=$(echo -e "Edit file\nEdit title\nEdit description\nEdit tags\nCancel" | rofi -width 15 -l 5-p "Now?:" -dmenu)
if [[ $choice = "Edit file" ]]; then
touch $path/$filename.md
echo -e "---\ntitle: $title\nheader: $title\ndescription: $description\ntags: $tags\npermalink: /blog/$filen/\nlayout: post\ndate: $today $(date +"%T") -0600\nhost: fosstodon.org\nusername: joel\ncom_id: idcomments\n---">> $path/$filename.md
echo -e "This is day of [#100DaysToOffload](https://100daystooffload.com)" >> $path/$filename.md
echo -e "{% include reply.html %}" >> $path/$filename.md
num=1
alacritty -e nvim $path/$filename.md & disown
#cp $path/$filename.md ~/Documents
elif [[ $choice = "Edit title" ]]; then
title=$(rofi -l 0 -width 50 -p "Title" -dmenu)
elif [[ $choice = "Edit description" ]]; then
description=$(rofi -l 0 -width 60 -height 20 -p "Description" -dmenu)
elif [[ $choice = "Edit tags" ]]; then
tags=$(rofi -l 0 -width 45 -p "Tags" -dmenu)
else
num=1
fi
done