[英]Can I make an alias with a parameter?
So i want to run a script that requires me to input the name of a file. 所以我想运行一个脚本,要求我输入文件名。
For example: /userthatisnotme/bin/move filename
例如: /userthatisnotme/bin/move filename
So I want to make it easier for me to remember, so I can just type move filename
instead of that whole path. 所以我想让我更容易记住,所以我可以只输入move filename
而不是整个路径。
How can I do this? 我怎样才能做到这一点?
In your bash_profile (or other shell profile script): 在您的bash_profile(或其他shell配置文件脚本)中:
alias my_move="/userthatisnotme/bin/move"
Examples of aliases for ls here: http://github.com/adamv/dotfiles/blob/master/bashrc#L45 此处的ls别名示例: http : //github.com/adamv/dotfiles/blob/master/bashrc#L45
The "parameters" get placed after the alias name. “参数”放在别名之后。 For more complicated situations, you could make a shell function instead of an alias. 对于更复杂的情况,您可以使用shell函数代替别名。
use a sub routine. 使用子例程。
mymove(){
/userthatisnotme/bin/move "$1"
}
save this in your library eg mylibrary
. 将其保存在您的库中,例如mylibrary
when you want to use it, just source it. 当您要使用它时,只需提供它即可。 . mylibrary
. mylibrary
or source mylibrary
. mylibrary
或源mylibrary
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.