Termux-app: Persistent Home Directory

Created on 11 Jul 2018  路  6Comments  路  Source: termux/termux-app

What I'm looking for is a nice, convenient way to store configuration settings for externally running applications in Termux. For example, when I install Midnight Commander (mc) or pip install youtube-dl or edit my ~/.vimrc or ~/.bashrc, etc... I would like my settings to still exist even when I remove Termux, even by accident (somehow).

Let's say, I give Termux storage permissions (now possible starting with Nougat). So then, somewhere in /sdcard/ directory, I should then be able to make a directory where I can store dotfiles and settings for applications, like a "second home folder" if you will.

Is it as simple as using a home directory symlink, or appending something to $PATH, or is this more complex?

Something more of a streamlined solution would be great to add to Termux!

Most helpful comment

You can keep the in a git project. After installing termux you can then do git clone smth and run a script/make/w/e to cp or ln them to HOME.

Just be sure to not put sensitive information in them (if you use github or other public git site).

There's also the vcsh package (available in termux) which aims at simplifying/improving this further. I haven't tested it though.

All 6 comments

Okay, so far using a symlink works.

Here's what I did:

  1. Make sure storage permissions are enabled
  2. Enter cd ~/..
  3. Move/create home directory to a destination such as /sdcard/Android/data/com.termux/home, make sure to rm -rf home/ if creating one.
  4. Enter ln -s /sdcard/Android/data/com.termux/home home
  5. Restart Termux and run again

EDIT: Never mind. Doesn't work very well since the /sdcard directory has no execute permissions, and doesn't support symbolic links inside this directory...

You can keep the in a git project. After installing termux you can then do git clone smth and run a script/make/w/e to cp or ln them to HOME.

Just be sure to not put sensitive information in them (if you use github or other public git site).

There's also the vcsh package (available in termux) which aims at simplifying/improving this further. I haven't tested it though.

I don't really like using Git to sync home directories like that. Besides, the home directory that I use on my desktop is way significantly more bloated than I need it to be. Likely the case for most people.

I've just added this to my .bashrc for now:

alias termux-backup-home="tar czf /sdcard/Termux-home.tar.gz -C ~ ."
alias termux-restore-home="tar xf /sdcard/Termux-home.tar.gz -C ~"

Whatever floats your boat!

Just note that you won't be syncing your home directory, the .git resides elsewhere and you can easily choose to only sync some dotfiles to termux, not all that you have on your desktop.

Closing as implementable on "user level" - use either symlinks, backups via git, tar or other solutions.

Implementing "backup" feature in terminal application is overkill - shell provided by Termux gives user enough freedom to do this in preferred way.

I'm Using a Simple Shortcut

Just edit the bash.bashrc file
and add the needed lines

HOME=/path/you/need
cd $HOME

give the path to your Folder in Internal Storage to the variable. That's all.

It'll Permanently Make the Changes

Was this page helpful?
0 / 5 - 0 ratings