Artificial intelligent assistant

Check if I'm in a shell through ranger In ranger, you can hit `S` to jump into a shell and `ctrl+D` to get back to ranger. When I've been in a shell for a while and I want to jump to ranger, I'm unsure if this is a regular shell and I should hit `ranger` or if I'm in the shell through ranger already and I should hit `ctrl+D`. If I hit `ctrl+D` wrongly, my terminal will close. If I use `ranger` wrongly, I'll get a nested instance of ranger within ranger. Is there a way to check if I'm already in a ranger shell? If there is a command, I could alias it to something like `rangerp` which will output "True" if I am in a shell and "False" if I'm not.

Looking at the parent pid helps regarding this.


[root@centos8 ranger-1.9.3]# ps -fp $PPID
UID PID PPID C STIME TTY TIME CMD
root 3240 3214 0 08:03 pts/1 00:00:00 /usr/bin/python3 -O /usr/local/bin/ranger
[root@centos8 ranger-1.9.3]#


So try


ps -fp $PPID | grep -q ranger && echo True || echo False

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy e028d1b3ddf107a007c30fbd1660ce70