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.
alias rakesolr='cd dir; rake sunspot:solr:start; cd -'
works for me (in bash). Does that do what you need?
[ Ahh, semicolon ! Michael.]
Maybe can you edit your rake task ? Or you can make a new task that do a Dir.chdir and then execute the task wanted.
Edit : resource about execute a task within another here
为什么不编写一个小的bash脚本,cds然后执行脚本并通过别名命令运行?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.