[HN Gopher] Better adb shell
___________________________________________________________________
Better adb shell
Author : matan-h
Score : 88 points
Date : 2024-04-15 07:16 UTC (15 hours ago)
(HTM) web link (github.com)
(TXT) w3m dump (github.com)
| thrdbndndn wrote:
| > one alias to fix the typo sl => ls.
|
| I'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.
| jdowner wrote:
| It's not for me. I can see the appeal of these shortcuts, but I
| can see it being a wtf down the road once I've forgotten that I
| have them in place.
|
| 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.
| hyperhopper wrote:
| Or, just install sl!
|
| 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)
| themoonisachees wrote:
| I have a magic enter plugin that just runs 'll' when I input
| no command and press enter, I haven't typed ll in months!
| t8sr wrote:
| This is similar, but actually gives you additional tools and a
| statically compiled bash: https://github.com/wowsignal-
| io/android-tools
| farmerbb wrote:
| Seems to be tailored specifically for Apple Silicon Macs,
| considering that it attempts to spin up an AArch64 Docker
| container to compile some of its tools.
| kytazo wrote:
| I ended up just resorting in bash with an exec bash inside my
| mkshrc iirc.
|
| 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.
| matan-h wrote:
| I've tried it. nushell works for me only with the "-c" option,
| otherwise I get "Error: I/O error: Function not implemented (os
| error 38)". Probably the prompt function
| dzaima wrote:
| Of note of course is termux, which is a proper terminal, complete
| with a custom apt repo.
|
| 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.
| matan-h wrote:
| I use this to copy programs from termux.
|
| 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=. ./bash
| gardnr wrote:
| I prefer adb hell.
|
| https://stackoverflow.com/questions/18097790/adb-hell-comman...
| vodkapump wrote:
| adb lolcat and adb longcat are also neat ones
| sva_ wrote:
| $ adb hell adb: unknown command hell
| DownrightNifty wrote:
| From one of the SO comments: https://android-
| review.googlesource.com/c/platform/system/co...
|
| It was removed :(
|
| Kinda funny that the commit message doesn't say anything like
| "remove hell mode", it's integrated into another unrelated
| patch
| pif wrote:
| "rmtree" and "untar" look too much like: #define
| BEGIN {
|
| When on Unix, do as Unixers do.
| dzaima wrote:
| Given that unzip and unxz exist, untar isn't that unreasonable.
| chasil wrote:
| As an aside, mksh hasn't been updated since 2020.
|
| This is not as bad as ksh93, but it is starting to look more like
| abandonware, implying that oksh is healthier.
|
| http://www.mirbsd.org/mksh.htm
| natrys wrote:
| No new release doesn't mean abandonware though, upstream last
| commit was 2 weeks ago.
| frusdroid wrote:
| Since adb rarely comes up on Hacker News, I got only one shot to
| ask how other Android uses deal with the problem of freeing up
| disk space without rooting the device or doing a factory reset?
| The number of apps is not the problem. Some apps or the OS must
| be filling directories with inaccessible temporary files or
| perhaps the OS is keeping all its old updates somewhere? On a 32M
| device 15 megs is lost over the course of a year. All the obvious
| user space tooling cannot clear or access it.
| chasil wrote:
| Maybe two options...
|
| 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...
| folower wrote:
| Can adb show true android disk space usage without a rooted
| device? Either the Android system or some app is consuming
| half of my storage but I have no idea what or where it is.
| The missing storage doesn't even show up in the disk usage
| view and total app storage used is tiny by comparison.
| chasil wrote:
| I am on the latest LineageOS, and "df -h" does give me a
| lot of information, along with a reasonable figure for the
| device size under /storage/emulated.
|
| 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.
| adr1an wrote:
| I was able to remove YouTube thanks to Canta + Shizuku.
| Unfortunately, the latest android OTA upgrade breaks canta. But
| I'm already free of YouTube and enjoying NewPipe \o/
| faust201 wrote:
| Always see the main folder Android inside /storage/emulated/0
|
| Apps like Instagram or WhatsApp or even Podcast apps DUMP
| everything there. Many dont clear even if one uninstalls.
| matan-h wrote:
| aka /sdcard on most phones
| causality0 wrote:
| I gave into temptation and bought a device I can't root. Two
| years on, I'm resolved to never make that mistake again.
| j4hdufd8 wrote:
| It's not physically possible to buy a device you can't root.
| You can however buy a device that is not easy to root.
| causality0 wrote:
| You are aware Samsung encrypts the bootloader of their
| American devices, yes? If you have a way to decrypt Android
| 12+ Samsung bootloaders I know two separate people running
| unlock businesses who would love to pay you a lot of money.
| xyzzy_plugh wrote:
| I feel as though I am a dying breed, as nothing about this seems
| "better" than the default. The PS1 is enriched with information,
| sure, but I find it very distracting. I much prefer $ or #.
| alanbernstein wrote:
| Do you never look at your scrollback, or a command+result
| pasted into a text file? I find it useful to include the
| context of working directory and timestamp, adjacent to the
| command.
| chasil wrote:
| In startup.sh, here are a few things to think about.
|
| 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)"
| matan-h wrote:
| Apart from the length, what advantages does `[-z $VAR ] &&
| VAR=x` over `if [ ! $VAR ]; then VAR=x fi` ?
|
| Btw, The color script is cool. This makes ANSI sensible.
| chasil wrote:
| I don't think there are any functional or performance
| differences between these forms: [ -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 -f
| gizmo686 wrote:
| If -e is set you can use || and invert the condition.
| retrochameleon wrote:
| Still trying to find a functional tool that makes it easy to take
| full backups and restore them to android devices since adb
| deprecated the "backup" command
___________________________________________________________________
(page generated 2024-04-15 23:01 UTC)