Search code examples
ruby-on-railsrubyscopeconstantsclass-variables

How can I make an alias both cd and run a script or run a script in a non-home directory


How can I make an alias either run a script in another directory or both cd and run the script?

I have commands in my .bashrc file to cd /home/myname/my_dir

and also

rake sunspot:solr:start  

when I am in our app directory (that contains the /script subdirectory).

I have not been able to put either put the directory in the rake command or have the alias do a cd and then the rake command that it currently does.

For instance I attempted rake /home/my_dir/out_code_directory/sunspot:solr:start RAILS_ENV=test but that didn't work.


Solution

  • alias rakesolr='cd dir; rake sunspot:solr:start; cd -'
    

    works for me (in bash). Does that do what you need?

    [ Ahh, semicolon ! Michael.]