Loading .shell/aliases +2 −0 Original line number Diff line number Diff line Loading @@ -40,4 +40,6 @@ alias ipyhton2=ipython2 alias ipyhton3=ipython3 . ~/.shell/lib/virtualenv.bash # vim: ft=sh .shell/lib/shared.sh +29 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,35 @@ has() } >/dev/null 2>&1 basename_filter() { case ${1-} in -z) _bf_readargs="-d ''" ;; esac while read ${_bf_readargs-} name; do basename "$name" done unset _bf_sep } case $CURRENT_SHELL in zsh) eval ' splitpaths() { local substr for substr in ${(s.:.)1}; echo "$substr" } ' ;; bash) splitpaths() { local IFS=: substr for substr in ${1}; do echo "$substr"; done } ;; esac if has realpath; then expand() { realpath $1; } elif has readlink; then Loading .shell/lib/virtualenv.bash 0 → 100644 +46 −0 Original line number Diff line number Diff line [ -n "${SOURCED_VIRTUALENV_FUNCS-}" ] && return SOURCED_VIRTUALENV_FUNCS=yes . ~/.shell/lib/shared.sh has splitpaths || return _venv_glob_path() { local dir pattern splitpaths "$PATH" | while read -r dir; do for pattern in "$@"; do case "$dir/$pattern" in *[^a-zA-Z0-9-_./*?]*) die "Bad pattern: $dir/$pattern" ;; esac ( case $CURRENT_SHELL in bash) shopt -u failglob; shopt -s nullglob ;; zsh) setopt CSH_NULL_GLOB ;; esac set +e eval 2>/dev/null "printf '%s\n' $dir/$pattern" ) done done } _venv_make_func() { local python version local platform=`uname -s | tr A-Z a-z` for python in $(_venv_glob_path 'python3.*'|basename_filter|sort -u); do version=$(tr -d . <<<"${python#python}") alias pydevenv${version}="_venv_enable $version $platform $python" done } _venv_enable() { local venv=.venv${1}-${2} [[ -d "$venv" ]] || virtualenv "$venv" -p$(which ${3}) source "$venv/bin/activate" } _venv_make_func Loading
.shell/aliases +2 −0 Original line number Diff line number Diff line Loading @@ -40,4 +40,6 @@ alias ipyhton2=ipython2 alias ipyhton3=ipython3 . ~/.shell/lib/virtualenv.bash # vim: ft=sh
.shell/lib/shared.sh +29 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,35 @@ has() } >/dev/null 2>&1 basename_filter() { case ${1-} in -z) _bf_readargs="-d ''" ;; esac while read ${_bf_readargs-} name; do basename "$name" done unset _bf_sep } case $CURRENT_SHELL in zsh) eval ' splitpaths() { local substr for substr in ${(s.:.)1}; echo "$substr" } ' ;; bash) splitpaths() { local IFS=: substr for substr in ${1}; do echo "$substr"; done } ;; esac if has realpath; then expand() { realpath $1; } elif has readlink; then Loading
.shell/lib/virtualenv.bash 0 → 100644 +46 −0 Original line number Diff line number Diff line [ -n "${SOURCED_VIRTUALENV_FUNCS-}" ] && return SOURCED_VIRTUALENV_FUNCS=yes . ~/.shell/lib/shared.sh has splitpaths || return _venv_glob_path() { local dir pattern splitpaths "$PATH" | while read -r dir; do for pattern in "$@"; do case "$dir/$pattern" in *[^a-zA-Z0-9-_./*?]*) die "Bad pattern: $dir/$pattern" ;; esac ( case $CURRENT_SHELL in bash) shopt -u failglob; shopt -s nullglob ;; zsh) setopt CSH_NULL_GLOB ;; esac set +e eval 2>/dev/null "printf '%s\n' $dir/$pattern" ) done done } _venv_make_func() { local python version local platform=`uname -s | tr A-Z a-z` for python in $(_venv_glob_path 'python3.*'|basename_filter|sort -u); do version=$(tr -d . <<<"${python#python}") alias pydevenv${version}="_venv_enable $version $platform $python" done } _venv_enable() { local venv=.venv${1}-${2} [[ -d "$venv" ]] || virtualenv "$venv" -p$(which ${3}) source "$venv/bin/activate" } _venv_make_func