plugin/python: `shfmt`

My apologies to future `git blame` hunters ♥
pull/2016/head
John D Pell 2022-01-01 22:59:32 -08:00
parent dd911f1256
commit 29216c0fd4
2 changed files with 19 additions and 19 deletions

View File

@ -106,6 +106,7 @@ plugins/available/nodenv.plugin.bash
plugins/available/percol.plugin.bash
plugins/available/plenv.plugin.bash
plugins/available/pyenv.plugin.bash
plugins/available/python.plugin.bash
plugins/available/rbenv.plugin.bash
plugins/available/ruby.plugin.bash
plugins/available/textmate.plugin.bash

View File

@ -1,32 +1,31 @@
cite about-plugin
# shellcheck shell=bash
about-plugin 'alias "shttp" to SimpleHTTPServer'
if _command_exists python2; then
alias shttp='python2 -m SimpleHTTPServer'
elif _command_exists python
elif _command_exists python; then
alias shttp='python -m SimpleHTTPServer'
else
return 1
fi
function pyedit() {
about 'opens python module in your EDITOR'
param '1: python module to open'
example '$ pyedit requests'
group 'python'
about 'opens python module in your EDITOR'
param '1: python module to open'
example '$ pyedit requests'
group 'python'
xpyc="$(python -c "import os, sys; f = open(os.devnull, 'w'); sys.stderr = f; module = __import__('$1'); sys.stdout.write(module.__file__)")"
xpyc="$(python -c "import os, sys; f = open(os.devnull, 'w'); sys.stderr = f; module = __import__('$1'); sys.stdout.write(module.__file__)")"
if [[ "$xpyc" == "" ]]; then
echo "Python module $1 not found"
return -1
elif [[ "$xpyc" == *__init__.py* ]]; then
xpydir="${xpyc%/*}";
echo "$EDITOR $xpydir";
${VISUAL:-${EDITOR:-${ALTERNATE_EDITOR:-nano}}} "$xpydir";
else
echo "$EDITOR ${xpyc%.*}.py";
${VISUAL:-${EDITOR:-${ALTERNATE_EDITOR:-nano}}} "${xpyc%.*}.py";
fi
if [[ "$xpyc" == "" ]]; then
echo "Python module $1 not found"
return 1
elif [[ "$xpyc" == *__init__.py* ]]; then
xpydir="${xpyc%/*}"
echo "$EDITOR $xpydir"
${VISUAL:-${EDITOR:-${ALTERNATE_EDITOR:-nano}}} "$xpydir"
else
echo "$EDITOR ${xpyc%.*}.py"
${VISUAL:-${EDITOR:-${ALTERNATE_EDITOR:-nano}}} "${xpyc%.*}.py"
fi
}