This repository has been archived by the owner on Aug 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
S90_python
69 lines (57 loc) · 1.45 KB
/
S90_python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Coloring for python's nose test-running tool
export NOSE_REDNOSE=1
python_module_dir() {
python -c "import $1, os; print os.path.dirname($1.__file__)"
}
cdpy() {
cd "$(python_module_dir $1)"
}
mkpkg() {
mkdir -p "$1"
if [ -e "$1".py ]; then
mv "$1".py "$1"/__init__.py
rm -f "$1".pyc
else
touch "$1"/__init__.py
fi
}
mkvenv() {
if [ -d $1 ]; then
echo refusing to use existing directory $1
return 1
fi
mkdir -p $1
cd $1
virtualenv .venv
act
if [ x"$2" = x"+" ]; then
pip install $1
elif [ -n "$2" ]; then
shift
pip install "$@"
fi
}
GLOBAL_VIRTUALENV_NAME="__global__"
function venv_prompt() {
reset_prompt;
if [[ "${VIRTUAL_ENV:t}" != "$GLOBAL_VIRTUALENV_NAME" ]]; then
PS1="%{$bg[magenta]%}${VIRTUAL_ENV:t}$rst$PS1"
fi
}
function _complete__fab { reply=(`fab -l -F short`); }
compctl -K _complete__fab fab
[ -z "$PIP_DOWNLOAD_CACHE" ] && { mkdir -p ~/.pip/cache && export PIP_DOWNLOAD_CACHE=${HOME}/.pip/cache; }
function newpy() {
local template_dir="$HOME/.zsh.d/static/newpy"
if [ "$1" = "-L" ]; then
ls $template_dir
return 2
fi
if [ ! -e ${template_dir}/$1.py ]; then
ls ${template_dir}/$1.py
echo "no such template $1"
return 1
fi
cp ${template_dir}/$1.py $2
}
[ -f /usr/local/opt/mess/bin/activate ] && alias mess="source /usr/local/opt/mess/bin/activate"