Start Local Jekyll Server and Open Safari Macro

Start local Jekyll server and open Safari Macro

No matter how hard I try, "bundle exec jekyll serve" are the 4 English words I cannot remember in the proper order, so I made this macro, that CDs to my site folder, launch the Jekyll local server and, after a few second, open the local address in Safari.

Hope it's useful!

Start local Jekyll server and open Safari.kmmacros (2,1 KB)

1 Like

Hey Cesare,

If you're running that in the Terminal then you might as well consolidate it some:

cd path/to/my/jekyll/website/folder; bundle exec jekyll serve; sleep 10; open -a Safari

Note – you don't wan't a pipe after the first command – you want a command terminator (semi-colon).


Thank you! It makes perfectly sense to do everything in Terminal. I'm not sure about the difference between pipe and semicolon, but I'll Google it. Thanks again!

Just in case you never got around to googling that, a pipe character takes the output from one command and sends it to the input of the next command. Piping the output from STDOUT of the first to STDIN of the next. The semicolon character is similar to a newline as far as the shell is concerned, it just says "do this command, then do the next command".

I think if this were up to me, I'd probably write it like:

cd path/to/my/jekyll/website/folder && bundle exec jekyll serve && sleep 10 && open -a Safari

The && operator tells the shell to only execute the next command if the previous one completed successfully.

However, you've probably already discovered that this won't work either because jekyll serve won't run in the background, and we don't really want it to anyway. What we really want is a recent version of Jekyll and to run this command:

cd ~/path/to/site && jekyll serve -l -o

This will reload the site live as you make changes to it, and automatically open the site in your default browser.

1 Like

Oh, this is useful. Didn’t know about the -o switch.

Normally I have my local Jekyll site in a dedicated Fluid app window, but the -o will be very useful for quick stuff. Thanks for the hint!