Last active
August 29, 2015 14:07
-
-
Save jaredrummler/bd52e2f04b0e461be718 to your computer and use it in GitHub Desktop.
Use the terminal to enter text on Android devices.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
############################################# | |
# | |
# text.sh inputs text on Android devices | |
# using adb shell. | |
# | |
# author: Jared Rummler | |
# since: Oct 22, 2014 | |
# version: 1.0 | |
# | |
cat > ./temp.sh << EOF | |
#!/system/bin/sh | |
phrase="\$@" | |
length=\$(echo "\$phrase" | wc -w) | |
n=0 | |
for i in \$phrase | |
do | |
let n++ | |
input text \$i | |
if [ \$n -lt \$length ] | |
then | |
# Add a space between words. | |
input keyevent 62 | |
fi | |
done | |
EOF | |
adb="adb wait-for-device" | |
$adb push ./temp.sh /sdcard/temp.sh | |
$adb shell su -c "cp /sdcard/temp.sh /data/local/temp.sh" | |
$adb shell sh -c "rm /sdcard/temp.sh" | |
$adb shell su -c "chmod 0755 /data/local/temp.sh" | |
$adb shell su -c "sh /data/local/temp.sh $@" | |
$adb shell su -c "rm /data/local/temp.sh" | |
rm ./temp.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment