changed script to bash
This commit is contained in:
parent
f95885ab1d
commit
b531606ad1
2 changed files with 37 additions and 39 deletions
39
newpost.lua
39
newpost.lua
|
@ -1,39 +0,0 @@
|
||||||
#! /usr/bin/env lua
|
|
||||||
|
|
||||||
date = io.popen("date --rfc-3339=date"):read()
|
|
||||||
title = "null"
|
|
||||||
author = nil
|
|
||||||
|
|
||||||
|
|
||||||
function input()
|
|
||||||
print("Enter post title:")
|
|
||||||
title = io.read()
|
|
||||||
|
|
||||||
print("Enter author name:")
|
|
||||||
author = io.read()
|
|
||||||
end
|
|
||||||
|
|
||||||
function confirmation()
|
|
||||||
print("Is the following correct?")
|
|
||||||
print("title:",title)
|
|
||||||
print("author:",author)
|
|
||||||
print("y/n")
|
|
||||||
end
|
|
||||||
|
|
||||||
function main()
|
|
||||||
repeat
|
|
||||||
input()
|
|
||||||
confirmation()
|
|
||||||
until io.read() == "y"
|
|
||||||
local postname = "./posts/" .. date .. "-" .. title:gsub(" ", "-") .. ".md"
|
|
||||||
local metatab ="---\ntitle: " .. title .. "\nauthor: " .. author .. "\ntags: \ndescription: \n---"
|
|
||||||
if os.execute("touch " .. postname) then
|
|
||||||
os.execute("echo '" .. metatab .. "' >> ".. postname)
|
|
||||||
os.execute("vim " .. postname)
|
|
||||||
else
|
|
||||||
print("some error occured. exiting")
|
|
||||||
os.exit(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
main()
|
|
37
newpost.sh
Executable file
37
newpost.sh
Executable file
|
@ -0,0 +1,37 @@
|
||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
date=$(date --rfc-3339=date)
|
||||||
|
title=
|
||||||
|
author=
|
||||||
|
|
||||||
|
function input {
|
||||||
|
echo "Enter post title:"
|
||||||
|
read title
|
||||||
|
echo "Enter author name:"
|
||||||
|
read author
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirmation {
|
||||||
|
echo "Is the following correct?"
|
||||||
|
echo "title: $title"
|
||||||
|
echo "author: $author"
|
||||||
|
echo "y/n"
|
||||||
|
}
|
||||||
|
|
||||||
|
function main {
|
||||||
|
local conf="n"
|
||||||
|
while [ "$conf" != "y" ]
|
||||||
|
do
|
||||||
|
input
|
||||||
|
confirmation
|
||||||
|
read conf
|
||||||
|
done
|
||||||
|
set -x
|
||||||
|
postname="./posts/$date-${title// /-}.md"
|
||||||
|
echo -e "---\ntitle: ${title}\nauthor: ${author}\ntags: \ndescription: \n---" >> $postname
|
||||||
|
vim $postname
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
||||||
|
|
||||||
|
unset date title author
|
Loading…
Reference in a new issue