I'm using Ubuntu terminal to manage my works. I created some alias names that help me to do the work faster.
for example:
$ alias kprod="kubectl --namespace=hello"
Then use it like this:
$ kprod get pods
One of my major tasks is to find when is my application is ready to run on the cloud, so I call this code:
$ kprod get pods | grep APPNAME
But I need to run it again and again until it ready. I want to use watch
command to simplify this task. Unfortunately, watch not working because kprod
is an alias.
$ watch kprod get pods
sh: 1: kprod: not found
My Questions:
- Is this possible to solve this specific problem with
watch
shell command? Is it possible to make a more generic solution that will "translate" the command for the actual expression? For example:
$ kprod get pods | TRANSLATE kubectl --namespace=hello get pods
which make it work with watch
and any other application?
UPDATE
Using type
command is similar but different. As I tried, it's impossible to give it a full expression and "translate" it because it's trying to convert each token of the expression seperatly. Of cause the pod (in my example above) is not alias string...
For example:
$ type kprod get pods
kprod is aliased to `kubectl --namespace=hello'
-bash: type: get: not found
-bash: type: pods: not found
Yes, i can do it manually with the type
command, but it's manually. I looking for automated way.
which
,type
andalias
) and none of them get me into the this point. – No1Lives4Ever Jun 04 '19 at 07:39watch
. – terdon Jun 05 '19 at 11:29