how to run "cd" command in drush I like to have drush command 'go_to' that will move my shell into different directory. My custom implementation does not move the shell directory. How come? here is the script so far:

#!/usr/bin/env drush
&lt;?php

$dir = '/dir/to/move/my/shell';
drush_op('chdir', $dir);
drush_op_system('cd '.$dir);
//drush_shell_exec('cd '.$dir);
//print_r(drush_shell_exec_output());


Thank you for help
The "cd" command in your commandfile is working correctly; however, it is a standard behavior for *nix (and Windows) that environment variables, such as the current working directory variable set by the 'cd' command apply only to the process that they are set in.  Drush runs in a separate process from the shell that you launch it from, so your current working directory will revert to its original value when Drush terminates.  (It actually never changed, since each process has its own environment.)

Instead of using a Drush alias (site alias or shell alias), what you might actually prefer is a bash alias.  For example:

$ alias go='cd /dir/to/move/my/shell'
$ go
$ pwd
/dir/to/move/my/shell


There's a lot more you can do here if you define site aliases for your site, and source the example bashrc file that Drush provides; see the Drush README file, and the examples folder.

If you want to write fancy php code change your working directory, you need to put only the code that calculates the destination path, and then call 'cd' from a shell alais.  For example (from bash):

$ alias go='cd $(drush dd @mysite)'
$ go
$ pwd
/path/to/drupal/root/of/mysite


This one liner will also do the trick:

$ cd `drush @mysite dd`


zsh aliases have the same syntax as bash aliases: 

http://zsh.sourceforge.net/Intro/intro_8.html  


It also looks like process substitution has the same syntax in zsh as well:

http://zsh.sourceforge.net/Intro/intro_7.html#SEC7


However, I haven't tried any of this in zsh.