Bash has a hook (cannot remember the name on my phone) that is called on every command.
It's easy enough to write into a file the command together with the directory and git branch.
Then I can grep it with a bash function that colors the dir and branch in the output.
It does not replace ctrl-r but it's a great addition especially when running multiple sessions and bash saving just the last one