Question

I have set up some aliases in my ~/.bash_profile file for simple GitHub tasks such as:

gp="git push"
gs="git status"

I would like to be able to set two more for git add and git commit so that it will ask me for input.

ga="git add" -> Which file(s) would you like to add? $path_to_file
gc="git commit -m" -> Please add a message: $user_input
Was it helpful?

Solution

For that you need to use a function in ~/.bash_profile instead of an alias.

For example, something like this can make it:

git_commit () {
        read -p "Add a message? " -r user_input
        git commit -m "$user_input"
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top