From be1e716cd82ab9be24c1040b37db53fe61ae96eb Mon Sep 17 00:00:00 2001 From: Holger Just Date: Thu, 14 Apr 2022 17:29:16 +0200 Subject: [PATCH] Detect python3 when starting a simple http server --- .bashrc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.bashrc b/.bashrc index bf4c6d0..b58347e 100644 --- a/.bashrc +++ b/.bashrc @@ -279,8 +279,12 @@ alias rc="bundle exec rails console" ss() { if [[ -x script/server ]]; then bundle exec script/server webrick -b 127.0.0.1 "$@"; else rs $@; fi } sc() { if [[ -x script/console ]]; then bundle exec script/console "$@"; else rc "$@"; fi } http() { - port=${1:-8000} - python -m SimpleHTTPServer $port + port="${1:-8000}" + if type python3 >/dev/null 2>&1; then + python3 -m http.server "$port" + else + python -m SimpleHTTPServer "$port" + fi } # if cat is called on a directory, call ls instead