使用bash_profile自定义终端命令

问题描述:

我正在尝试运行一个新的命令,它运行一个需要参数的shell脚本。使用bash_profile自定义终端命令

所以,我在.bash_profile中有命令:

command() { 
    /Users/myname/filepath/MyScript.sh 
} 

但MyScript.sh可以在参数。那么,如何修改此代码来处理参数,以便它将这些参数传递给MyScript.h?

我认为你正在寻找一个bash别名:

alias mycommand="/Users/myname/filepath/MyScript.sh [email protected]" 

假设你希望所有的参数命令去MyScript.sh,那就试试这个:

command() { 
    /Users/myname/filepath/MyScript.sh "[email protected]" 
}