Commits

Doug Hellmann committed 9efe38b

add showvirtualenv and re-implement lsvirtualenv with it

Comments (0)

Files changed (1)

virtualenvwrapper.sh

 }
 
 _lsvirtualenv_usage () {
-    echo "lsvirtualenv [-lh]"
+    echo "lsvirtualenv [-blh]"
+    echo "  -b -- brief mode"
+    echo "  -l -- long mode"
+    echo "  -h -- this help message"
 }
 
 # List virtual environments
 #
 # Usage: lsvirtualenv [-l]
 lsvirtualenv () {
-    typeset args=$(getopt lh $*)
+    typeset args=$(getopt blh $*)
     if [ $? != 0 ]
     then
         _lsvirtualenv_usage
         return 1
     fi
-    typeset long_mode=false
+    typeset long_mode=true
     for opt in $args
     do
         case "$opt" in
             -l) long_mode=true;;
+            -b) long_mode=false;;
             -h) _lsvirtualenv_usage;
                 return 1;;
         esac
     then
         for env_name in $(virtualenvwrapper_show_workon_options)
         do
-            echo -n "$env_name"
-            virtualenvwrapper_run_hook "get_env_details" "$env_name"
-            echo
+            showvirtualenv "$env_name"
         done
     else
         virtualenvwrapper_show_workon_options
     fi
 }
 
+# Show details of a virtualenv
+#
+# Usage: showvirtualenv [env]
+showvirtualenv () {
+    typeset env_name="$1"
+    if [ -z "$env_name" ]
+    then
+        if [ -z "$VIRTUAL_ENV" ]
+        then
+            echo "showvirtualenv [env]"
+            return 1
+        fi
+        env_name=$(basename $VIRTUAL_ENV)
+    fi
+
+    echo -n "$env_name"
+    virtualenvwrapper_run_hook "get_env_details" "$env_name"
+    echo
+}
+
 # List or change working virtual environments
 #
 # Usage: workon [environment_name]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.