First off, I have read the post here: Bash alias create file with current timestamp in filename
However, when I run it, I keep getting the same timestamp. This makes no sense to me.
I am running Git bash (From git 2.16.2) on Windows 10. I have added the following line into my ~/.bash_aliases:
alias logfile="adb logcat -v threadtime *:V | tee /c/Users/username/Desktop/adb-logs/'$(date +%Y-%m-%d@%Hh%Mm%Ss)'-FullLogCat.log"
This seems to create a log file and display the ADB logs on screen, as I want. However, the actual date seems to be "stuck" at the same time as the terminal is loaded. For example, I load the terminal at 2:29:09pm then wait until 2:30:00pm to call the alias, the file gets stamped as "2018-04-24@14h29m09s-FullLogCat.log". It seems like as the profile loads the aliases into memory, it executes the date function.
Is there a way to prevent this? Is this just a weird git bash thing?
Update: Solution
alias logfile='adb logcat -v threadtime *:V | tee /c/Users/ghannan/Desktop/adb-logs/''$(date +%Y-%m-%d@%Hh%Mm%Ss)''-FullLogCat.log