How to modify Bash shell prompt in Cyanogenmod? Has anyone had any success modifying the shell prompt in Cyanogenmod? Presently, # is pretty useless, it would be much nicer to at least display the working directory. Also, is tab-completion possible?
I'm not too keen on the why, but sh on CyanogenMod is a bit watered down. As Joachim noted in the comments, usually you can modify PS1 to change your prompt, but it doesn't properly expand prompt variables:

# ps $$  &lt;-- Just showing that the current shell is /system/bin/sh
ps $$
USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME
root      1055  129   756    340   c006abb8 afd0c44c S /system/bin/sh
# echo $PS1
echo $PS1
#
# PS1="\w # "
PS1="\w # "
\w #   &lt;-- \w should be PWD


However, CyanogenMod does ship with a modified version of sh called ash (I believe this is for Android Shell), which does support a subset of these prompt variables. Here's some examples of what does and doesn't work, with local echo removed for the sake of clutter/space:

# ash
~ # echo $PS1
\w \$
~ # PS1="\u \w \\$ "
root ~ # PS1="\t \w \\$ "
         ~ # PS1="\l \w \\$ "
l ~ # PS1="\H \w \\$ "
H ~ # PS1="\h \w \\$ "  
localhost ~ # cd /sdcard
localhost /mnt/sdcard #


As for tab-completion: I don't personally know of a way to make this work. I imagine the main problem is actually that the adb shell buffers input up until you press enter, so the tab isn't actually sent to the shell program when you hit it. A good illustration of this is to open a file with more. The q key exits the more program, but you actually have to press q and then hit enter to quit because the initial q keystroke isn't sent until you press enter to send the whole buffer.



Okay, SSH is a different beast. Assuming you have a reasonably sane client ash will give you tab-completion along with the prompt variable expansion noted above. If you're using dropbear (the ssh daemon that ships with CyanogenMod) then you can configure ash to be the default prompt by logging into your device (either SSH or adb shell works here) and doing the following:

# echo "/system/xbin/ash" &gt; /data/dropbear/.profile


This assumes /data/dropbear/.profile doesn't yet exist, because it will overwrite any existing version (this file is not created automatically, though). It can be edited instead if the file already exists, of course. Then restart dropbear and log in again. You should land at an ash session:

login as: root
Authenticating with public key "rsa-key-20110718"
TRACE (1391): entering fake-getpwnam
TRACE (1391): leaving fake-getpwnam
TRACE (1391): enter sign_key_free
TRACE (1391): enter dsa_key_free
TRACE (1391): leave dsa_key_free
TRACE (1391): enter rsa_key_free
TRACE (1391): leave rsa_key_free
TRACE (1391): leave sign_key_free
/data/dropbear # ps $$
USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME
root      1392  1391  1084   416   c006abb8 afd0c44c S /system/xbin/ash
/data/dropbear #