Skip to content
Advertisement

alias with bash involving current system time

I have the problem with macOS mojave, but I guess it generalizes to all bash environment. In the .bashrc or .profile, I add one line as:

JavaScript

My purpose is to send the current system time as a message when commiting a change by typing gc. However, the system time was read when alias was invoked (here is when I log in the system). Can anyone help me out? Thank you in advance!

Advertisement

Answer

The simpler approach is to make this a shell function and not an alias at all:

JavaScript

That said, as a matter of good git hygeine, I strongly advise against doing this; you’ll get output files and temporary files you don’t want checked in. git commit -a, by not adding new files, is somewhat safer — though using git add -p to review changes hunk-by-hunk is by far the best practice to avoid mixing unrelated and unwanted changes into your commits.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement