This repository was archived by the owner on Mar 31, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathbashrc
More file actions
90 lines (76 loc) · 1.57 KB
/
bashrc
File metadata and controls
90 lines (76 loc) · 1.57 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# settings
PATH_WITHOUT_PYTHONZ=$PATH
PATH_ROOT="$PYTHONZ_ROOT"
if [ -z "${PATH_ROOT}" ] ; then
PATH_ROOT="$HOME/.pythonz"
fi
PATH_ETC="$PATH_ROOT/etc"
PATH_HOME="$PYTHONZ_HOME"
if [ -z "${PATH_HOME}" ] ; then
PATH_HOME="$HOME/.pythonz"
fi
PATH_HOME_ETC="$PATH_HOME/etc"
# py file
PY_PYTHONZ="$PATH_ROOT/bin/pythonz"
# completion
PYTHONZ_COMPLETION="$PATH_ETC/bash_completion.d/pythonz_completion.sh"
# functions
__pythonz_set_path()
{
[[ ":$PATH:" = *":$PATH_ROOT/bin:"* ]] || PATH=$PATH_ROOT/bin:$PATH
}
__pythonz_reload()
{
[[ -s "$PATH_ETC/bashrc" ]] && source "$PATH_ETC/bashrc"
}
__pythonz_update()
{
$pythonz "$@"
[[ $? == 0 ]] && __pythonz_reload
}
__pythonz_find_command()
{
command_name=""
for arg in "$@" ; do
case $arg in
--*) continue;;
-*) continue;;
*)
command_name=$arg
break
;;
esac
done
}
__pythonz_run()
{
__pythonz_find_command "$@"
case $command_name in
update) __pythonz_update "$@" ;;
*) $pythonz "$@" ;;
esac
builtin hash -r
}
pythonz()
{
pythonz=$PY_PYTHONZ
__pythonz_run "$@"
}
sudo-pythonz()
{
pythonz="sudo PYTHONZ_ROOT=$PATH_ROOT PATH=$PATH_PYTHONZ:$PATH_WITHOUT_PYTHONZ $PY_PYTHONZ"
__pythonz_run "$@"
}
__pythonz_bash_completion()
{
if [ -s "$PYTHONZ_COMPLETION" ];then
. $PYTHONZ_COMPLETION
fi
}
# main
__pythonz_set_path
# nebale completion on bash >= 4
if [ ${BASH_VERSION} ] && [ ${BASH_VERSION:0:1} -ge 4 ]; then
__pythonz_bash_completion
declare -A _pythonz_context
fi