TRAMP
After setting up your SSH connection you can use TRAMP to access files on emacs, which is easier for browsing files using dired. You can visit the home folder, for example, with
C-x C-f /ssh:user@IP#8022:/data/data/com.termux/files/home/`
Where IP
is the IP of the phone relative to the laptop (192..
).
It can run shells too (3 different shells actually) inside emacs, e.g. M-x shell /ssh:user@IP#8022:/data/data/com.termux/files/usr/bin/bash
You might run into problems running programs with this shell inside emacs like I did because the environment variable $PATH
(which tells your computer where to look for programs to execute) was not set correctly because it was using a different startup script than what I was getting with normal SSH.
To learn more about this, you can read about {login,nonlogin}{interactive,noninteractive} shells
(the general idea is that different systems load different startup scripts). I don’t know which ones TRAMP uses but I know (through trial and error) that is uses ~/.bashrc
.
So, I added the following to ~/.bashrc
and now programs accessed from the shell within emacs work:
export PATH="$PATH:/data/data/com.termux/files/usr/bin" # where termux keeps programs
export PATH="$PATH:$HOME/bin" # if you have programs in that folder