Have aliases in adb shell non-interactive mode Have aliases in adb shell non-interactive mode unix unix

Have aliases in adb shell non-interactive mode


If your android device is rooted you can add your aliases for adb shell into the /system/etc/mkshrc file.


One way to do this is to issue several shell commands in a single ADB command. You can put them in a string, and separate them with semicolons, thus:

adb shell "alias foo bar ; export MY_VARIABLE=/path/to/somewhere ; my_executable "

The " are crucial here, make sure they are paired up correctly. You could run your .bashrc this way, thus:

adb shell "source /path/to/.bashrc ; my_executable"


You can write a bash script that sets the aliases and then executes your shell:

#!/usr/bin/bash. $HOME/.bashrcadb shell $@