watch command alias expansion

If a run the watch command having an alias, it will certainly not expand the alias. I have attempted both with solitary quote and also double quotes, actually offered the adhering to alias:

# alias ll
alias ll='ls -l --color=tty'

The adhering to command will fall short

# watch ll
sh: ll: command not found

Shouldn't regulate line development operate in this instance?

108
2022-06-05 17:37:56
Source Share
Answers: 2

I assumed below standard trouble is while implementing watch, the argument is provided to "sh -c" which suggests if alias ll is not specified in sh(dash shell's) setting after that it will certainly not expand it. Yet I was incorrect and also this is not the instance, Chris' solution over is right.

1
2022-06-05 17:51:52
Source

Aliases are just increased as the first argument, or after an additional alias with a routing room on completion of the command.

From bash is help alias:

A routing room in VALUE creates the next word to be looked for alias replacement when the alias is increased.

To do this, attempt the following:

alias watch='watch '
alias ll='ls -l --color=tty'
watch ll

Bear in mind that some variations of watch strip colours by default, on some variations this can be dropped in making use of --color or -G.

169
2022-06-05 17:49:09
Source

Related questions