diff options
author | EuAndreh <eu@euandre.org> | 2024-09-11 17:42:58 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-09-11 17:42:58 -0300 |
commit | 620b5f9d57d1e8d7392c81194b255c83ec2d9db1 (patch) | |
tree | fd05b2f47a6456c0312145bb972b292633f350ae /bin/serve | |
parent | rm bin/untill: Moved to eut (diff) | |
download | dotfiles-620b5f9d57d1e8d7392c81194b255c83ec2d9db1.tar.gz dotfiles-620b5f9d57d1e8d7392c81194b255c83ec2d9db1.tar.xz |
bin/serve: Add -n option
Diffstat (limited to 'bin/serve')
-rwxr-xr-x | bin/serve | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -5,7 +5,7 @@ set -eu usage() { cat <<-'EOF' Usage: - serve [-d DIRECTORY] [-p PORT] + serve [-d DIRECTORY] [-n] [-p PORT] serve -h EOF } @@ -16,6 +16,7 @@ help() { Options: -d DIRECTORY the directory to serve (default: ".") + -n do not open browser -p PORT the port to listen on (default: find one) -h, --help show this message @@ -55,7 +56,8 @@ done DIRECTORY='.' PORT="$(free-port)" -while getopts 'd:p:h' flag; do +OPEN_BROWSER=true +while getopts 'd:np:h' flag; do case "$flag" in (d) DIRECTORY="$OPTARG" @@ -63,6 +65,9 @@ while getopts 'd:p:h' flag; do (p) PORT="$OPTARG" ;; + (n) + OPEN_BROWSER=false + ;; (h) usage help @@ -75,6 +80,8 @@ while getopts 'd:p:h' flag; do esac done -open "http://localhost:$PORT" & +if [ "$OPEN_BROWSER" = true ]; then + open "http://localhost:$PORT" & +fi python3 -m http.server -d "$DIRECTORY" "$PORT" wait |