0

Is there a way to configure .bash_history to show the pwd of each command issued?

My ~/.bash_history file has these contents:

git commit -am "git-hooks" --no-verify
git push
teros_install_git_hooks ; echo $?
chmod -R /Users/alex/codes/teros/vcs-hooks/.githooks -w

but I would like to show something like:

git commit -am "git-hooks" --no-verify   (/Users/me/foo)
git push   (/Users/me/foo)
teros_install_git_hooks ; echo $?   (/var/root/.ssh)
chmod -R /Users/alex/codes/teros/vcs-hooks/.githooks -w (/var/root/.ssh)
Bergi
  • 572,313
  • 128
  • 898
  • 1,281
Alexander Mills
  • 78,517
  • 109
  • 412
  • 724
  • 1
    What do you mean by `the pwd of each command`? Do you mean the directory you were in when you issued the command (i.e. the output of `pwd`) or the directory the command existed in when you executed it (e.g. the output of `which command`) or something else? – Ed Morton May 13 '19 at 19:38
  • @EdMorton the dir where the command was issued from – Alexander Mills May 13 '19 at 19:53
  • That's still very ambiguous. Again - is that the directory you were in when you called the command or the directory the command was in when it was called? If I'm in directory `/foo/bar` when I call command `/usr/bin/stuff` should the log contain `/foo/bar` or `/usr/bin`? – Ed Morton May 13 '19 at 19:55
  • I don't see how that's ambiguous, it would be /foo/bar, but sure it might also be nice to log `which stuff` too. – Alexander Mills May 13 '19 at 20:05
  • `the dir where the command was issued from` means either `the dir I was in when I called the command` or `the dir the command was in when I called it`. Hence the ambiguity. Thanks for clarifying. – Ed Morton May 14 '19 at 02:35
  • 1
    if it was unclear to you it is probably unclear to others will fix it – Alexander Mills May 14 '19 at 02:41

0 Answers0