When I do
$ watch kubectl get pods
it works fine but on doing:
$ alias p0="kubectl get pods" $ watch p0
gives an error:
Every 2.0s: p0
sh: p0: command not found
It looks like watch is starting a subshell and the aliases in my current shell aren't visible to the subshell. I do have
$ shopt -s expand_aliases
at the very top of my .bashrc but it isn't helping.
Trying this with bash version 3.2.57 on Mac OS Mojave.
Update: Tried a few more things:
$ watch -n 0.1 "source ~/.bashrc; shopt; alias p0; p0"
still doesn't work.
cdable_vars off cdspell off checkhash off checkwinsize off cmdhist on compat31 off dotglob off execfail off expand_aliases on extdebug off extglob off extquote on failglob off force_fignore on gnu_errfmt off histappend on histreedit off histverify off hostcomplete on huponexit off interactive_comments on lithist off login_shell off mailwarn off no_empty_cmd_completion off nocaseglob off nocasematch off nullglob off progcomp on promptvars on restricted_shell off shift_verbose off sourcepath on xpg_echo on p0='kubectl get pods' <--- HERE'S THE ALIAS sh: p0: command not found <--- STILL DOESN'T EXECUTE IT.