I am writing a simple script to change the current working directory to another directory. The following script works fine until the program exits, after which I will return to my home directory.
import os
if __name__ == '__main__':
os.chdir("/home/name/projects/python")
os.system("pwd")
print 'dir changed'
Output:
bash:~$ python chdir.py
/home/name/projects/python
dir changed
bash:~$ pwd
/home/name
I want the directory change to remain even after the program exits. Any ideas how to do this?
Edit : I really want to do this: I often use this directory and instead of doing it cd <path>every time I open the terminal, I just write ./prognameand change the directory.
source
share