mirror of
https://github.com/dcarrillo/prezto.git
synced 2025-07-01 19:49:25 +00:00
Compare commits
1 Commits
issue/231-
...
pull/517-a
Author | SHA1 | Date | |
---|---|---|---|
e3696d2c28 |
@ -61,6 +61,29 @@ system site-packages directory.
|
|||||||
|
|
||||||
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
|
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
|
||||||
|
|
||||||
|
### Settings
|
||||||
|
|
||||||
|
#### Lazy loading
|
||||||
|
|
||||||
|
By default, virtualenvwrapper is loaded in lazy mode. This behaviour can be disabled adding the following line to *~/.zpreztorc*:
|
||||||
|
|
||||||
|
zstyle ':prezto:module:python' lazy_venv 'no'
|
||||||
|
|
||||||
|
#### Automatic virtualenv initialization
|
||||||
|
|
||||||
|
To enable autoenv, add the following line to *~/.zpreztorc*:
|
||||||
|
|
||||||
|
zstyle ':prezto:module:python' autoenv 'yes'
|
||||||
|
|
||||||
|
If a virtualenv is active, and was not activated by autoenv, then autoenv does nothing.
|
||||||
|
Otherwise, autoenv activated or deactivates a virtual environment whenever a directory is changed; based on the following priority:
|
||||||
|
|
||||||
|
1. Name specified in a file named *.venv* in the cwd.
|
||||||
|
2. *.venv* file in git root. If folder is inside git repository.
|
||||||
|
3. Name of git root folder.
|
||||||
|
4. No virtualenv.
|
||||||
|
|
||||||
|
|
||||||
Aliases
|
Aliases
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
@ -31,17 +31,66 @@ if (( ! $+commands[python] && ! $+commands[pyenv] )); then
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local venv_script=virtualenvwrapper
|
||||||
|
if zstyle -T ':prezto:module:python' lazy_venv; then
|
||||||
|
venv_script+=_lazy
|
||||||
|
fi
|
||||||
|
|
||||||
# Load virtualenvwrapper into the shell session.
|
# Load virtualenvwrapper into the shell session.
|
||||||
if (( $+commands[virtualenvwrapper_lazy.sh] )); then
|
if (( $+commands[$venv_script.sh] )); then
|
||||||
# Set the directory where virtual environments are stored.
|
# Set the directory where virtual environments are stored.
|
||||||
export WORKON_HOME="$HOME/.virtualenvs"
|
export WORKON_HOME="$HOME/.virtualenvs"
|
||||||
|
|
||||||
# Disable the virtualenv prompt.
|
# Disable the virtualenv prompt.
|
||||||
VIRTUAL_ENV_DISABLE_PROMPT=1
|
VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||||
|
|
||||||
source "$commands[virtualenvwrapper_lazy.sh]"
|
source "$commands[$venv_script.sh]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
function autoenv {
|
||||||
|
#Don't run in shell scripts etc.
|
||||||
|
if [[ $ZSH_SUBSHELL -ne 0 ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Don't run if currently in virtual env not set by autoenv
|
||||||
|
if (( ($+VIRTUAL_ENV) && !($+AUTOENV) )); then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local name=""
|
||||||
|
if [[ -f .venv ]]; then
|
||||||
|
#.venv file in current dir gets highest priority
|
||||||
|
name=$(<.venv)
|
||||||
|
elif is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
|
||||||
|
local gitroot="$(git rev-parse --show-toplevel 2> /dev/null)"
|
||||||
|
if [ -f "$gitroot/.venv" ]; then
|
||||||
|
#If there is a .venv file in gitroot
|
||||||
|
name=$(<$gitroot/.venv)
|
||||||
|
else
|
||||||
|
#Else use the name of the folder as venv name
|
||||||
|
name=$gitroot:t
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
local venv_name="$VIRTUAL_ENV:t"
|
||||||
|
if [[ $name != $venv_name ]]; then
|
||||||
|
if [[ -z $name ]]; then
|
||||||
|
deactivate && unset AUTOENV
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -d "$WORKON_HOME/$name" ]]; then
|
||||||
|
workon $name && export AUTOENV=1
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if zstyle -T ':prezto:module:python' autoenv; then
|
||||||
|
add-zsh-hook chpwd autoenv
|
||||||
|
fi
|
||||||
#
|
#
|
||||||
# Aliases
|
# Aliases
|
||||||
#
|
#
|
||||||
|
57
tools/go.sh
57
tools/go.sh
@ -1,57 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
clear
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
hash zsh 2>/dev/null || {
|
|
||||||
echo "\033[0;31mFailed : ZSH is missing\033[0m"
|
|
||||||
echo " ➥ Prezto does not work without ZSH. Install it first."
|
|
||||||
echo ""
|
|
||||||
exit
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ -d ~/.zprezto ]
|
|
||||||
then
|
|
||||||
echo "\033[0;33mYou already have prezto installed.\033[0m Upgrading..."
|
|
||||||
cd ~/.zprezto
|
|
||||||
# git pull && git submodule update --init --recursive
|
|
||||||
/usr/bin/env git add .
|
|
||||||
/usr/bin/env git commit --all --message "Commit changes before upgrade" --quiet
|
|
||||||
/usr/bin/env git pull --recurse-submodules
|
|
||||||
/usr/bin/env git submodule update
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "\033[0;34mCloning prezto...\033[0m"
|
|
||||||
hash git >/dev/null && /usr/bin/env git clone --recursive https://github.com/loranger/prezto.git "${ZDOTDIR:-$HOME}/.zprezto" >/dev/null 2>&1 || {
|
|
||||||
echo "\033[0;31mFailed : Git is not installed\033[0m"
|
|
||||||
os=`uname`
|
|
||||||
if [ "$os" == 'Linux' ]; then
|
|
||||||
url='http://git-scm.com/download/linux'
|
|
||||||
elif [ "$os" == 'Darwin' ]; then
|
|
||||||
url='http://brew.sh/'
|
|
||||||
else
|
|
||||||
url='http://git-scm.com/'
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo " ➥ You should really take a look at $url"
|
|
||||||
exit
|
|
||||||
}
|
|
||||||
|
|
||||||
for file in $HOME/.zprezto/runcoms/z*
|
|
||||||
do
|
|
||||||
rcfile=`basename $file`
|
|
||||||
if [ -f $HOME/.$rcfile ] || [ -h $HOME/.$rcfile ]
|
|
||||||
then
|
|
||||||
echo "\033[0;33mFound ~/.$rcfile file.\033[0m \033[0;32mMoved to ~/.$rcfile.old\033[0m";
|
|
||||||
mv $HOME/.$rcfile $HOME/.$rcfile.old;
|
|
||||||
fi
|
|
||||||
ln -s $file $HOME/.$rcfile
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "\033[0;32mPrezto is ready\033[0m"
|
|
||||||
|
|
||||||
echo "\033[0;34mNow set zsh as your default shell by typing :\033[0m"
|
|
||||||
echo "chsh -s $(which zsh)"
|
|
||||||
echo "\033[0;34mand start a new term.\033[0m"
|
|
||||||
# https://raw2.github.com/loranger/prezto/master/go.sh
|
|
@ -1,97 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
script_name="${0:t}"
|
|
||||||
script_version='1.0.0'
|
|
||||||
cached_argv="${argv}"
|
|
||||||
backup_dir="$HOME/.prezto-backup/$(date +'%Y-%m-%d-%H-%M-%S')"
|
|
||||||
|
|
||||||
# Writes to standard error.
|
|
||||||
function print-error {
|
|
||||||
print "${script_name}: ${@}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
# Writes to standard output.
|
|
||||||
function print-info {
|
|
||||||
print "${@}" >&1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Writes version information to standard errror.
|
|
||||||
function version {
|
|
||||||
print "${script_name} ${script_version}
|
|
||||||
|
|
||||||
Copyright (c) 2013 Sorin Ionescu
|
|
||||||
|
|
||||||
This program is free software. You may modify or distribute it
|
|
||||||
under the terms of the MIT License." >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
# Writes help to standard error.
|
|
||||||
function help {
|
|
||||||
print "Usage: ${script_name} [‐option ...] archive [directory]
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-v, --version Display version and copyright
|
|
||||||
-h, --help Display this help
|
|
||||||
|
|
||||||
Report bugs to <sorin.ionescu@gmail.com>." >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
# Backs up existing files.
|
|
||||||
function backup {
|
|
||||||
local from="$1"
|
|
||||||
local to="$2"
|
|
||||||
|
|
||||||
if [[ ! -e "$from" ]]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p "$to:h"
|
|
||||||
mv "$from" "$to"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Parse switches.
|
|
||||||
while [[ "${1}" == -* ]]; do
|
|
||||||
case "${1}" in
|
|
||||||
( -v | --version )
|
|
||||||
version
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
( -h | --help )
|
|
||||||
help
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
( -- )
|
|
||||||
shift
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
( -* )
|
|
||||||
print-error "invalid option: ${1}"
|
|
||||||
help
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
|
|
||||||
setopt EXTENDED_GLOB
|
|
||||||
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
|
|
||||||
ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
|
|
||||||
done
|
|
||||||
chsh -s /bin/zsh
|
|
||||||
|
|
||||||
is-true "$use_color" && printf "$FG[green]"
|
|
||||||
printf '%s' \
|
|
||||||
'________ _____
|
|
||||||
___ __ \___________________ /______
|
|
||||||
__ /_/ /_ ___/ _ \__ /_ __/ __ \
|
|
||||||
_ ____/_ / / __/_ /_/ /_ / /_/ /
|
|
||||||
/_/ /_/ \___/_____/\__/ \____/
|
|
||||||
'
|
|
||||||
is-true "$use_color" && printf "$FG[cyan]"
|
|
||||||
print
|
|
||||||
print 'Prezto has been updated to the latest version.'
|
|
||||||
print 'Follow me on GitHub at https://github.com/sorin-ionescu/prezto.'
|
|
||||||
|
|
||||||
exec zsh
|
|
||||||
|
|
||||||
|
|
@ -1 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
Reference in New Issue
Block a user