How do I avoid typing “git” at the begining of every Git command?

后端 未结 15 767
醉酒成梦
醉酒成梦 2021-01-29 22:31

I\'m wondering if there\'s a way to avoid having to type the word git at the beginning of every Git command.

It would be nice if there was a way to use the

15条回答
  •  走了就别回头了
    2021-01-29 22:57

    In your example, you compare it to a MySql prompt. The way that works is that a MySql process starts, and you give your commands to that process. As such, why not write something similar in your language of choice? Here's a simple example in C++:

    #include 
    #include 
    
    int main(int argc, char *argv[]){
        while(true){
            std::cout << "git> ";
            std::cout.flush();
            std::string command;
            std::getline(std::cin, command);
            if(command == "exit") break;
            std::system("git " + command);
        }
    
        return 0;
    }
    

    Please note that I just wrote that from memory and that I didn't check it with a compiler. There may be trivial syntax errors.

提交回复
热议问题