I am trying to write a program that will change the current directory in zsh
without creating a new instance of zsh
. Might sound confusing but what I've tried so far should help with that.
Say zsh
is currently in the "Users" directory as in:
$ /Users/ →
If I run the following on Python:
os.system("cd projects")
os.system("zsh")
It changes zsh
to the "Projects" directory:
$ /Users/ → python main.py
$ /Users/Projects/ →
But this creates a new instance of zsh
and running exit
doesn't close the Terminal window. Instead, I'll need to rerun exit
.
Is there anyway to get Python to change current directory in zsh
without starting up another instance of it?