Home > Enterprise >  How to create an alias composed of many commands?
How to create an alias composed of many commands?

Time:05-06

Commands are:

git checkout master
git remote add upstream [email protected]:minio/console.git
git fetch upstream
git checkout master
git rebase upstream/master

What I want is to type one word and get all of them executed

CodePudding user response:

You don't have to do anything special. Just put all the commands in the alias.

alias aliasname='git checkout master
git remote add upstream [email protected]:minio/console.git
git fetch upstream
git checkout master
git rebase upstream/master'

CodePudding user response:

You can define an alias that executes multiple commands, simply by using the ; to separate the comamnds: git checkout master ; git remote ...

But then, consider to simply write a small helper script instead.

CodePudding user response:

What I would do is:

File: ~/.zshrc

Content:

function updateForkedConsoleRepo() {
    git checkout master
    git remote add upstream [email protected]:minio/console.git
    git fetch upstream
    git rebase upstream/master
    echo "git push if all goes well"
}

Now with one word you can execute all your commands:

$ source ~/.zshrc
$ updateForkedConsoleRepo                                  
  • Related