37 lines
1002 B
Bash
37 lines
1002 B
Bash
cite about-plugin
|
|
about-plugin 'alias "shttp" to SimpleHTTPServer'
|
|
|
|
# Load after pyenv
|
|
# BASH_IT_LOAD_PRIORITY: 285
|
|
|
|
# Check python version to ensure pyenv can find python
|
|
{ _command_exists python && python --version &>/dev/null ; } || return 0
|
|
|
|
if [[ "$(uname -s)" == 'Linux' ]] ; then
|
|
alias shttp='python2 -m SimpleHTTPServer'
|
|
else
|
|
alias shttp='python -m SimpleHTTPServer'
|
|
fi
|
|
|
|
function pyedit() {
|
|
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__)")
|
|
|
|
if [[ "$xpyc" == "" ]]; then
|
|
echo "Python module $1 not found"
|
|
return -1
|
|
|
|
elif [[ $xpyc == *__init__.py* ]]; then
|
|
xpydir=`dirname $xpyc`;
|
|
echo "$EDITOR $xpydir";
|
|
$EDITOR "$xpydir";
|
|
else
|
|
echo "$EDITOR ${xpyc%.*}.py";
|
|
$EDITOR "${xpyc%.*}.py";
|
|
fi
|
|
}
|