Reputation: 153
When this command is run, it is not the time to submit the command, But print the source ~/.zshrc
time.
~/.zshrc:
alias gitCommitAll="git add . && git commit -m \"`date +\"%T\"`\""
eg.
source ~/.zshrc
at 10:00
gitCommitAll
at 10:10 ==> git commit -m "10:00"
not 10:10
Upvotes: 2
Views: 136
Reputation: 531055
Don't use an alias; use a function instead. It makes quoting far easier. Something like
gitCommitAll () {
git add . && git commit -m "$(date +%T) $1"
}
How you handle the argument(s) to the function depend on what you intended the alias to do. It looks like you meant for all (or at least the first) "argument" to be part of the -m
option, as a time alone isn't much of a commit message. The above just includes the first argument as part of the message.
Upvotes: 2
Reputation: 339
Try this:
alias gitCommitAll='git add . && git commit -m "`date +%T`"'
Backquote (``) inside double quotes (""
) will be executed prematurely. Try using single quotes (''
) instead.
Upvotes: 2