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
This isn't possible, to my knowledge, since they're different processes. If you need to affect the Ruby script's parent process (Bash), Bash will need to source something. So you could have your Ruby script output some bash commands, then have a Bash wrapper that source's Ruby's output.
Try this as an example, in Bash:
`ruby -e 'puts "cd /tmp"'` | source /dev/stdin
But this will only work in Bash 4.0.
EDIT:
Actually, you can do this with eval instead of source in Bash 3:
eval $(ruby -e'puts "cd /tmp"')