I\'d like to know if it\'s possible to change the current terminal directory from where I\'m executing my ruby script.
For example, if I\'m executing the script from
I doubt there is a straightforward way to do this.
When you launch a program from your login shell, underneath the hood it's doing a fork/exec which means a new (child) process is created (which has its own environment, such as current working directory) and it's standard input/output/error streams are associated with the (parent) shell process. So when your script calls Dir.chdir
it changes the current working directory for the script (child) process, not the parent.
Perhaps your script could launch a new shell before it exits, so it looks like your terminal has changed directory. Although, you'd have to exit from that extra shell before exiting your terminal session...