mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-06 02:51:32 +01:00
merge
This commit is contained in:
parent
a8c56f5231
commit
8274156fae
296 changed files with 6279 additions and 3141 deletions
|
|
@ -1,5 +1,5 @@
|
|||
# python command
|
||||
alias py='python3'
|
||||
# set python command if 'py' not installed
|
||||
builtin which py > /dev/null || alias py='python3'
|
||||
|
||||
# Find python file
|
||||
alias pyfind='find . -name "*.py"'
|
||||
|
|
@ -44,18 +44,19 @@ function pyuserpaths() {
|
|||
alias pygrep='grep -nr --include="*.py"'
|
||||
|
||||
# Run proper IPython regarding current virtualenv (if any)
|
||||
alias ipython="python3 -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"
|
||||
alias ipython='python3 -c "import IPython, sys; sys.exit(IPython.start_ipython())"'
|
||||
|
||||
# Share local directory as a HTTP server
|
||||
alias pyserver="python3 -m http.server"
|
||||
|
||||
|
||||
## venv utilities
|
||||
: ${PYTHON_VENV_NAME:=venv}
|
||||
|
||||
# Activate a the python virtual environment specified.
|
||||
# If none specified, use 'venv'.
|
||||
# If none specified, use $PYTHON_VENV_NAME, else 'venv'.
|
||||
function vrun() {
|
||||
local name="${1:-venv}"
|
||||
local name="${1:-$PYTHON_VENV_NAME}"
|
||||
local venvpath="${name:P}"
|
||||
|
||||
if [[ ! -d "$venvpath" ]]; then
|
||||
|
|
@ -72,12 +73,26 @@ function vrun() {
|
|||
echo "Activated virtual environment ${name}"
|
||||
}
|
||||
|
||||
# Create a new virtual environment, with default name 'venv'.
|
||||
# Create a new virtual environment using the specified name.
|
||||
# If none specfied, use $PYTHON_VENV_NAME
|
||||
function mkv() {
|
||||
local name="${1:-venv}"
|
||||
local name="${1:-$PYTHON_VENV_NAME}"
|
||||
local venvpath="${name:P}"
|
||||
|
||||
python3 -m venv "${name}" || return
|
||||
echo >&2 "Created venv in '${venvpath}'"
|
||||
vrun "${name}"
|
||||
}
|
||||
|
||||
if [[ "$PYTHON_AUTO_VRUN" == "true" ]]; then
|
||||
# Automatically activate venv when changing dir
|
||||
auto_vrun() {
|
||||
if [[ -f "${PYTHON_VENV_NAME}/bin/activate" ]]; then
|
||||
source "${PYTHON_VENV_NAME}/bin/activate" > /dev/null 2>&1
|
||||
else
|
||||
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
add-zsh-hook chpwd auto_vrun
|
||||
auto_vrun
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue