Updated Bash script to generate URI for Broswer

March 2017 ยท 1 minute read

Here’s a simple script that lets you throw URI date directly to the browser to render.

We want something that looks like:


Running stuff as command line arguements you have to escape '<' and '>'
(at least in Bash you do)
Another consideration is that browsers and commands do not like whitespace,
replace with '%20'

currentt=$(date) #linux date command
p='Body information!'

a="data:text/html,<h1>" #open header
b="</h1><p>" #close header open body
c="</p>" #close body

url=$a$h1$b$p$c #concatinate strings

url=${url// /%20} #replace all spaces with %20

firefox $url #open browser with link

A little tidbit from the URI standard that’s often overlooked! https://en.wikipedia.org/wiki/Data_URI_scheme