IF YOU JUST SOLVED SOME PROBLEM, WELCOME TO DM qaRabbit ON TWITTER, OR CREATE A PULL REQUEST IN GITHUB REPO.
Why hugo dev server can't open browser tab automatically?
Modify hugo source code will definitely solve this issue.
Or we can use two simpler ways:
use some program to run command
hugo server
andopen_browser
in paralleluse simple command sleep
Here is the second way on macOS: (open command only works on macOS)
#!/bin/bash
LOCAL_URL=http://localhost:1313
open_browser () {
duration=${1:-3}
sleep $duration
echo 'After '$duration
# change open command to proper one
open --new -a "Google Chrome" --args $LOCAL_URL
}
open_browser 1 &
hugo server
Reference:
https://github.com/gohugoio/hugo/issues/6293
https://www.cyberciti.biz/faq/how-to-run-command-or-code-in-parallel-in-bash-shell-under-linux-or-unix/
https://zwbetz.com/open-a-new-google-chrome-tab-or-window-via-command-line-on-mac"
Top comments (0)