virtualenvwrapper: Replace "realpath" with portable zsh-native `:A` and `:h` modifiers
Diff
1diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
2index 9fd0d3d8fd6163af1c6709830885eeff411fec02..f5f37ff6f573a2f8303ac7498d9b96d46a2b6b80 100644
3--- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
4+++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
5@@ -30,16 +30,17 @@ if [[ "$WORKON_HOME" == "" ]]; then
6 fi
7 8 if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
9- # Automatically activate Git projects's virtual environments based on the
10+ # Automatically activate Git projects' virtual environments based on the
11 # directory name of the project. Virtual environment name can be overridden
12 # by placing a .venv file in the project root with a virtualenv name in it
13 function workon_cwd {
14 if [ ! $WORKON_CWD ]; then
15 WORKON_CWD=1
16 # Check if this is a Git repo
17- PROJECT_ROOT=`pwd`
18+ # Get absolute path, resolving symlinks
19+ PROJECT_ROOT="${PWD:A}"
20 while [[ "$PROJECT_ROOT" != "/" && ! -e "$PROJECT_ROOT/.venv" ]]; do
21- PROJECT_ROOT=`realpath $PROJECT_ROOT/..`
22+ PROJECT_ROOT="${PROJECT_ROOT:h}"
23 done
24 if [[ "$PROJECT_ROOT" == "/" ]]; then
25 PROJECT_ROOT="."
26@@ -50,7 +51,7 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
27 elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then
28 ENV_NAME="$PROJECT_ROOT/.venv"
29 elif [[ "$PROJECT_ROOT" != "." ]]; then
30- ENV_NAME=`basename "$PROJECT_ROOT"`
31+ ENV_NAME="${PROJECT_ROOT:t}"
32 else
33 ENV_NAME=""
34 fi