Make a Bash alias that takes a parameter?

后端 未结 20 1941
长发绾君心
长发绾君心 2020-11-21 06:53

I used to use CShell (csh), which lets you make an alias that takes a parameter. The notation was something like

alias junk=\"mv \\\\!* ~/.Trash\"

20条回答
  •  独厮守ぢ
    2020-11-21 07:24

    You don't have to do anything, alias does this automatically.

    For example, if i want to make git pull origin master parameterized, i can simply create an alias as follows:

    alias gpull = 'git pull origin '
    

    and when actually calling it, you can pass 'master' (the branch name) as a parameter, like this:

    gpull master
    //or any other branch
    gpull mybranch
    

提交回复
热议问题