Termux - Custom Prompt

Termux is a terminal emulator and Linux environment for Android. I wanted to customise my prompt in the same way that I have done on my desktop/laptop machines. Ordinarily I would have a .bashrc in my home directory where I would make the changes to the prompt (PS1). However Termux doesn’t recognise this.

I found a reference to configuring this: http://blog.ataboydesign.com/2015/12/01/termux-is-the-one-for-android/

Following this method the changes to PS1 are made in “/data/data/com.termux/files/usr/etc/bash.bashrc”. I had been successfully using this method for a while with no ill effects. That was until today when I realised an update to Termux had overwritten the changes. Not what I wanted.

So after some searching I have found a solution that should survive future updates. In your Termux home directory save the following as “.profile”. This will be run when Termux is started and make Termux look for a “.bashrc” file in the home directory.
~/.profile
1
2
3
4
5
6
7
8
9
# .profile
if [ -n "BASH_VERSION" ]; then
    # Echo msg to indicate file is run - can be removed later
    echo "Profile load.bashrc"
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi

Create and edit “.bashrc” with any custom options. Exit and restart Termux and your custom configuration should be loaded.

jhonadan bae
dibae100@gmail.com
112.186.68.233
2019-03-17
15:47:49
thanks ... you are really helped me...
unsmigo
unamigo@vfemail.net
89.128.249.93
2019-12-06
08:31:03
How can I change the root # prompt in Termux?
Quantum
wordpress@deltanova.co.uk
86.175.113.188
2019-12-10
23:31:24
You need to edit the .bashrc file in the root users home directory.