Zsh Alias | Mac OS - No such file or directory but exists

1.6k Views Asked by At

I'm trying to create an alias to activate any given Venv by typing activate [name of Venv].

What I've done:

activate (){
    directory = "~/Programming/path-to-venvs/$1"
    cd $directory
    source "bin/activate"
}

When I try to run it, if I do:

activate Test

I get this error:

activate:cd:3: no such file or directory: ~/Programming/path-to-venvs/Test
activate:source:4: no such file or directory: bin/activate

Any ideas?

1

There are 1 best solutions below

0
mtnezm On BEST ANSWER

Just to close this question properly:

Use absolute paths instead of relative paths in your function.

Also you may be interested in reading this answer.