~snooze's home in town

< back

my first bash script - a sitegen

right! so where do i start! oh before i begin, i have to say im not much of a writer, so don’t expect this post to be concise or anything hehe ^^’

so, being in tilde-town is a very unique expecience. it is very much a social media like experience, but its much more calmer and friendlier imo. so i thought i might as well make my space on here somewhat personal by writing a sitegen. ive written sitegens before, but never one in bash, so i thought i might as well try it. i ended up finishing it, and this very site is made with it, hehe.

so i started out with planning out how exactly i wanted to interface with a site that i’d build with this tool. i had a general idea that i was going to use markdown to write my content because its cleaner markup compared to html and if i really wanted to do something fancy with js or something, id probably not use my sitegen for it :p. so i ended up with the following basic things that i’d like my sitegen to do: - init to probably start a new site - new to make a new post - publish to run pandoc and convert all my markdown files into html

as of now, this is all my sitegen does lol. its really basic, but it’s been doing the job well so far and im happy for now.

if you want to try it for yourself for whatever reason, you can get it using the following command:


    curl https://tilde.town/~snooze/share/mksite > mksite
    chmod +x ./mksite

PS: i found a really cool trick with sed that allowed me to replace a string in a file with the complete contents of another file. this might be useful to you too hehe


    pattern="pattern" # pattern you want to match and replace with
    sed -i -e "/$pattern/r file_with_content" -e "/$pattern/d" file_to_modify