Does anyone know how to run commands from adb shell and remain in shell session? What I`m trying to achieve is to set aliases in adb shell.
I have tried the followi
There was a similar question answered in the comments here.
In short, run the following from your terminal:
stty raw -echo ; ( echo "ls" && cat ) | adb shell ; stty sane
Note: without the stty
magic, the command is piped to adb
and tab complete etc. is not recognized.
expect
solution
adb-cmd
:
#!/usr/bin/env expect
spawn adb shell
expect "#"
send [ concat [ join $argv " " ] ]
send "\r"
interact
Usage:
adb-cmd 'cd /data/data; ls'
Tested in Ubuntu 16.04 host, Android O guest.
When you run:
adb shell ls
You are running this command currently outside of ADB.
First, you need to enter ADB:
adb shell
Once you enter ADB shell, you can continue to see output and input more commands.
ls
help
To exit ADB, simply type "exit" or hit "Ctrl + C"