macoszshzsh-alias

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


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?


Solution

  • 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.