Better adb shell
github.com
github.com
For any unprivileged user, find the bundled apps that are unused, uninstall updates, clear their storage, then disable them.
There is also a more thorough debloat method that does not require root. It seems to be in a state of flux as it is rewritten in Rust.
https://gitlab.com/W1nst0n/universal-android-debloater/-/blo...
I am using a ConnectBot local session to see this.
When I run this as root, the output of df is different, but it is not immediately obvious why.
If you can see the subdirectories, "du -sm *" will recurse and report usage by directory.
Apps like Instagram or WhatsApp or even Podcast apps DUMP everything there. Many dont clear even if one uninstalls.
Instead of setting RED/GREEN/BLUE, you could do this:
N=$(printf \\033)
N="$N[" x=30
for a in Bl R G Y B M C W # Black Red Green Yellow Blue Magenta Cyan White
do eval $a='$N'"'"$(( x))"m'" \
b$a='$N'"'"$((60 + x))"m'" \
${a}bg='$N'"'"$((10 + x))"m'" \
b${a}bg='$N'"'"$((70 + x))"m'" # bX=bright Xbg=background bXbg=brgt bgnd
x=$(( x + 1 ))
done # https://en.wikipedia.org/wiki/ANSI_escape_code
Unless you have "set -e" this: if [ ! "$HOSTNAME" ]; then
HOSTNAME="$(hostname -s)"
fi
Is more succinctly expressed as this: [ -z "$HOSTNAME" ] && HOSTNAME="$(hostname -s)"Btw, The color script is cool. This makes ANSI sensible.
[ -n "$var" ] || var=X
[ -z "$var" ] && var=X
if [ ! "$var" ]; then var=X; fi
It's a question of [your] style and taste, I think.There are a lot more ANSI sequences that I could work into that block, but it is quite thorough for the space it occupies.
BONUS:
Here is my script to extract all of the stored WiFi networks and passwords when run as root:
#!/bin/sh
find /data \
-name WifiConfigStore.xml \
-print0 |
xargs -0 awk '
/"SSID/ { s = 1 }
/PreShared/ { p = 1 }
s || p {
gsub(/[<][^>]+[>]/, "")
sub(/^[&]quot;/, "")
sub(/[&]quot;$/, "")
gsub(/[&]quot;/, "\"")
gsub(/[&]amp;/, "\\&")
gsub(/[&]lt;/, "<")
gsub(/[&]gt;/, ">")
}
s { s = 0; printf "%-32.32s ", $0 }
p { p = 0; print }
' | sort -fThe best normie backup tool is probably Neo Backup on F-Droid, and it's buggy and lacks some important features. Titanium is dead. I've not been satisfied with any of the various closed-source paid apps on the Play Store.
Any true backup is going to require rooting your phone. It's not in google's interest to allow you, the user, to access core operating system files and configuration on their device.
If you don't 0wn it, you don't own it.
Here's what I do.
I install Magisk and the MagiskSSH module. This gives me a root ssh shell and I can rsync any file on the device, selinux context and all.
The system requires some excludes for remounted/mirrored directories, and then there's other things like cache directories that I don't need to backup, so I use a rsync filter file. rsync's --link-dest makes backups very very fast and reduces disk usage. I should really do this on a filesystem that does block-level de-duplication, but I don't really need to because it's efficient enough already. Each app has to be paused/frozen during the backup to ensure data integrity.
Restoring requires a bunch of hacky scripts. It's not pretty, but it works.
I have to send over the apk file and use Android's native "pm install" to install it from /data/local/tmp. There's some cases where this doesn't work and I have to install the app manually from the store or wherever (APEX and other mutli-apk crap).
Then my script freezes/disables the app, wipes the local data, copies the backup data, fixes the ownership, unfreezes the app, and it mostly usually sometimes works.
Figuring out all the commands to do this, like getting the AIDs of apps, is some dark art shit. I've been doing this since the very beginning on a G1.
Maybe some day I'll put my scripts out there and it will inspire someone to pick it up and make them easier to use, but it's never going to be a real solution.
Someone just needs to make a real backup app for Android.
It may not even run on some Android 13 and later devices due to a common error of not being able to detect root status.
Google for more info.
I think it was back on LineageOS 16 that it was actually broken for the entire release. It wasn't even possible to do a basic backup at all.
Google for "site:reddit.com does seedvault even work" for dozens and dozens of examples.
#define BEGIN {
When on Unix, do as Unixers do.For cases where an adb shell is needed (modify external storage, slightly more permissions if not rooted) it's approximately possible to just copy necessary executables and .so files from termux to /data/local/tmp/ for adb (with some LD_LIBRARY_PATH & co setup), allowing running bash, htop, etc.
in termux (you need lld [pkg i lld]):
mkdir /sdcard/.adb
cp `which bash` /sdcard/.adb
cp $(ldd `which bash`|cut -d ">" -f2) /sdcard/.adb
in adb shell: cd /data/local/tmp
cp /sdcard/.adb/bash
cp /sdcard/.adb/*.so
LD_LIBRARY_PATH=.
./bashI'm wondering what others think about such feature (in general, not just in this specific case).
On one hand, it won't negatively affect my personal usage in anyway, probably even beneficial; On the other hand, the "purist in me" feels very uncomfortable with this kind of features (probably to the detriment of myself).
Again, this is not a complainant at all. Just find it interesting.
Also with something like auto-correct, you have a visual affordance that alerts you to the change (with the option to override), which just happened when I misspelled 'forgotten' above. The shell doesn't have that so something just happens without any actual correction or indication the user may have made an error. Although I am not a 'fish' user, this is something that I think it does well.
https://www.cyberciti.biz/tips/displays-animations-when-acci...
Personally I have sl aliased to sl=sl && ls to make sure I break the habit of ever typing sl.
(Though also usually I'm typing ll which I have aliased to an ls with list mode and many details)
This is not as bad as ksh93, but it is starting to look more like abandonware, implying that oksh is healthier.
I switched to nushell a couple of months back and I haven't got the opportunity to rock it on android, really curious how it does.
It is supposed to support android as well if I'm not mistaken.
https://stackoverflow.com/questions/18097790/adb-hell-comman...
$ adb hell
adb: unknown command hellIt was removed :(
Kinda funny that the commit message doesn't say anything like "remove hell mode", it's integrated into another unrelated patch