Detect if running in Termux

I noticed there is an environment variable TERMUX_VERSION, is the presence of this variable a reliable way to detect if a bash script is running in Termux?
8 Replies
Catinette
Catinette6mo ago
searching is a skill, train it
Agent_E11
Agent_E11OP6mo ago
Bro... I have already. I have seen that thread already and the two solutions in that thread seem unnecessarily janky. Detecting the presence of an environment variable would be much simpler than greping for a string in $PREFIX or checking for the presence of a command
Catinette
Catinette6mo ago
or, like in the link i shared make your own variable
Agent_E11
Agent_E11OP6mo ago
That is what I would do if I had complete control of the system, but I am doing this for a neovim plugin that other people will be using, and I don't want the setup to be unnecessarily complicated
Catinette
Catinette6mo ago
too bad
Agent_E11
Agent_E11OP6mo ago
All I want to know is if $TERMUX_VERSION is a variable that I can count on to be set in the Termux shell
Catinette
Catinette6mo ago
well it should
Want results from more Discord servers?
Add your server