I can reverse tether now by using alias but it stops on adb shell command I made some aliases to quickly reverse tether.

alias t='r &amp;&amp; sh &amp;&amp; n'
alias n='netcfg rndis0 dhcp'
alias sh='ad shell'
alias r='ad kill-server &amp;&amp; ad start-server'
alias ad='adb'


I want to enter t (which turns on reverse tethering) but the aliased command doesnt do anything past sh

How to automate this better?

(I guess its because its not in first shell anymore but android adb shell)

UPDATE: I edited the .bashrc as answered by Stephen Schrauger but the command enters me into adb shell and when i disconnect usb cable I get netcfg: command not found


  The aliases are now:


alias t='r &amp;&amp; sz $n'
n='netcfg rndis0 dhcp'
alias sz='ad shell'
alias r='ad kill-server &amp;&amp; ad start-server'
alias ad='adb'


What is wrong now?

UPDATE2 moved here:Help with this ADB REVERSE Tethering Script?
This is more of a linux question, and it may need to be moved to superuser.se, but I can answer it.

On linux, you string commands using &amp;&amp; (or || or just ;). With &amp;&amp;, the first command must finish executing and have no error codes in order for the next command in the sequence to run.

In your setup, it looks like you want to open an ADB shell, and then run netcfg rndis0 dhcp on the adb shell. However, Linux doesn't do that. Instead, it is waiting for the ADB shell to exit without errors, after which time it will run netcfg rndis0 dhcp on the desktop computer's shell.

If you want to run a command on the Android device, you don't start an interactive ADB shell (the default); rather, you pass the command like so:


  adb shellnetcfg rndis0 dhcp


You'll need to change your alias for n to be a variable instead. Remove the alias directive so the line just reads n='netcfg rndis0 dhcp'. Then change your alias for t to be as follows


  alias t='r &amp;&amp; sh $n'