I have the following piece of code:
import os
unixshell=os.environ["SHELL"]
dir="/home/user/somewhere"
if os.path.isdir(dir):
os.chdir(dir)
os.system(unixshell)
This is part of a script I wrote to bookmark folders I visit often in the terminal. A part of the script goes (cd's) to the bookmarked directory. I use it in the following way
~/olddir$ bk.py go [handle to bookmarked directory]
~/bookmarkeddir$
But, the thing I don't like is that a new bash shell is created, so when I need logout, I have to press CTRL+D
multiple times.
The question is, can I change directory without creating a new shell? Is this possible using modules existent in python 2.4, or do I need to go to a higher version?
Edit: My question is more duplicate of this question: