Diff
1diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
2index 80576fb38b864c61ca1c7275aaf25aa000181b75..eadbb6696bc32077933f84e0c723d458a48955b8 100644
3--- a/autoswitch_virtualenv.plugin.zsh
4+++ b/autoswitch_virtualenv.plugin.zsh
5@@ -277,6 +277,21 @@ function _missing_error_message() {
6 printf "\n"
7 }
8
9+function randstr()
10+{
11+ local strlen="${1:=8}"
12+ local str
13+ local i
14+
15+ strchars="abcdefghijklmnopqrstuvwxyz123456789"
16+
17+ for ((i=0; i<strlen; i++)); do
18+ str="$str${strchars:$(( $RANDOM % ${#strchars} )):1}"
19+ done
20+
21+ printf "%s" "$str"
22+}
23+
24
25 # helper function to create a project environment for the current directory
26 function mkvenv()
27@@ -314,7 +329,7 @@ function mkvenv()
28 if [[ -f "$AUTOSWITCH_FILE" ]]; then
29 printf "$AUTOSWITCH_FILE file already exists. If this is a mistake use the rmvenv command\n"
30 else
31- local venv_name="$(basename $PWD)-$(pwgen 8 1)"
32+ local venv_name="$(basename $PWD)-$(randstr)"
33
34 printf "Creating ${PURPLE}%s${NONE} virtualenv\n" "$venv_name"
35
36@@ -399,13 +414,8 @@ function disable_autoswitch_virtualenv() {
37 # This seems important for "instant prompt" zsh themes like powerlevel10k
38 function _autoswitch_startup() {
39 add-zsh-hook -D precmd _autoswitch_startup
40-
41- if ! type pwgen 1>/dev/null; then
42- printf "${PURPLE}pwgen is required for zsh-autoswitch-virtualenv to run${NONE}\n"
43- else
44- enable_autoswitch_virtualenv
45- check_venv
46- fi
47+ enable_autoswitch_virtualenv
48+ check_venv
49 }
50
51 autoload -Uz add-zsh-hook