5

This one has been bugging me for a while: I want to use the marvelous GNU watch command to run a few custom aliases and functions that are defined in my .bashrc, but it is never able to run anything except bash built-ins or binaries.

watch -d foo

The output is always: foo: command not found

How can I make it inherit my environment or use the .bashrc?

Thank you.

Artem Russakovskii
  • 973
  • 3
  • 11
  • 25

2 Answers2

7

Do something like this watch bash -i -c 'alias -p' this should call bash, load your settings and then run whatever command you have after the -c

Zoredache
  • 128,755
  • 40
  • 271
  • 413
1

From man watch:

Note that command is given to "sh -c"

So it's not going to see your Bash aliases and functions.

Dennis Williamson
  • 60,515
  • 14
  • 113
  • 148