[英]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? 如何创建别名要么在另一个目录中运行脚本,要么同时运行cd并运行脚本?
I have commands in my .bashrc
file to cd /home/myname/my_dir
我的.bashrc
文件中的命令为cd /home/myname/my_dir
and also 并且
rake sunspot:solr:start
when I am in our app directory (that contains the /script subdirectory). 当我在我们的app目录(包含/ script子目录)时。
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. 我无法将目录放在rake命令中,或者让别名执行cd,然后执行当前执行的rake命令。
For instance I attempted rake /home/my_dir/out_code_directory/sunspot:solr:start RAILS_ENV=test
but that didn't work. 例如,我尝试了rake /home/my_dir/out_code_directory/sunspot:solr:start RAILS_ENV=test
但是没有用。
alias rakesolr='cd dir; rake sunspot:solr:start; cd -'
works for me (in bash). 适合我(在bash)。 Does that do what you need? 这样做你需要的吗?
[ Ahh, semicolon ! [啊, 分号! Michael.] 迈克尔。]
为什么不编写一个小的bash脚本,cds然后执行脚本并通过别名命令运行?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.