9to5cynic
Android Expert
Yes, you're on the right track. Where are you testing, though? Are you using Linux? I'm sure id -u does what you want, but it doesn't work in Android, or at least not with the version of busybox that I have. I just displays the same thing as id, without any arguments. Did you try the other bashrc that I uploaded? I kinda hacked it together, but it worked for me, and it uses id instead of whoami.
As for PS1, yeah, run that from adb shell. It should change your prompt into something slightly more readable (just the $ for normal user and # for root). What is the shell you're first using after you run adb shell, in the first place? I would think it'd still be sh, not bash.
EDIT: If id -u did what you're saying (displays 0 for root or some other number for other users), this is what I'd do:
My guess though, is that it would still have a string that looks like this:Code:if [ `id -u` == 0 ];then echo "root" else echo "some other user" fi
uid=0(root) or uid=0
or something like that. I'll be in front of a real linux box tomorrow to test that. Until then, it doesn't work quite right in Android, hence my silly little hack. It does seem to work, though. Try it out (the bashrc I posted a few posts up) and let me know if it works. If it does, I suggest you take a look at what I did. When I was learning all this stuff, I found that reading real script was the best way to learn things. Tutorials are wonderful, but seeing how this stuff is used practically is the best way to learn, in my opinion. That being said, my fix is sort of a weird hack, and it can probably be done in a cleaner way.
I was just trying to see if I could get the `id -u`==0 to work for me, that was before I knew it would work with the -u. Oh well.
The bashrc file is working great. The colors change, no annoying error messages.

As for adb shell, I guess that PS1 thing was actually working, I thought it would change the way the directories are being displayed, it did fix the $ and # issue though. Yeah it was using sh, but the directories are all named with the brackets before and after the actual name. (it's weird, because the issue only happens with the phone booted normal, in recovery it was working (as of last night) ).
But good work with the bashrc file. I thought I understood a good amount of the last one, but this one is just crazy!

Edit:
Okay, I'm trying out your script now, I think I was messing up with either the spacing, or (more likely) the brackets.
Hmm.. it was telling me Not Root for both, also in the line with the if [ `id -u`... part, it returns [1000: command not found ?
I'll keep fiddling around with it for a bit.


