Browse Source

utility: Check best-fit Python version for 'http-serve'

When creating `http-serve` alias, first check if Python is actually
available. And, if available, apply the most specific version.
master
Indrajit Raychaudhuri 3 years ago committed by Indrajit Raychaudhuri
parent
commit
c36acf72b7
  1. 13
      modules/utility/init.zsh

13
modules/utility/init.zsh

@ -184,10 +184,15 @@ fi
# Miscellaneous # Miscellaneous
# Serves a directory via HTTP. # Serves a directory via HTTP.
if (( $+commands[python3] )); then if (( $#commands[(i)python(|[23])] )); then
alias http-serve='python3 -m http.server' autoload -Uz is-at-least
else if is-at-least 3 ${"$(python --version 2>&1)"[(w)2]}; then
alias http-serve='python -m SimpleHTTPServer' alias http-serve='python -m http.server'
elif (( $+commands[python3] )); then
alias http-serve='python3 -m http.server'
else
alias http-serve='$commands[(i)python(|2)] -m SimpleHTTPServer'
fi
fi fi
# #

Loading…
Cancel
Save