Running vi in adb under Windows

13,291

Solution 1

You can do it with PuTTYTray. It's an improved version of PuTTY which features a number of additional features. One of such feature is Android adb support. To use it:

  • Select Adb as Connection type
  • Enter -d (for single usb device) or device serial number in the host field
  • ???
  • PROFIT!!!

PuTTYTray configuration

Solution 2

This is a late answer to your question in 2012. I found that if I run Windows PowerShell, I can do "vi" under the adb shell.

Launch PowerShell (use your Android SDK location, not mine)

PS C:\Users\Me> cd Downloads\Android\Sdk\Platform-Tools
PS C:\Users\Me\Downloads\Android\Sdk\Platform-Tools> .\adb shell
root@vbox86p:/ # cd data/data/com.mycorporation.myproj/shared_prefs
root@vbox86p:/data/data/com.mycorporation.myproj/shared_prefs # vi log_prefs

I only used simple vi commands like 'o', 'esc', and ':wq', but it worked well using the full screen (none of the garbage you would see in the Windows Command Prompt).

Solution 3

I've never had your exact problem, but it seems like Cygwin would be a good bet.

Share:
13,291

Related videos on Youtube

Chinmay Kanchi
Author by

Chinmay Kanchi

I'm a developer and data scientist with Enlyft (formerly iDatalabs). We're hiring engineers! Remote work available. https://enlyft.com/careers/

Updated on July 13, 2022

Comments

  • Chinmay Kanchi
    Chinmay Kanchi almost 2 years

    Very occasionally, I will want to edit a file, say /system/build.prop or /etc/hosts on my Android device. I find that the easiest way to do it is:

    c:\> adb shell
    $ su
    # vi /etc/hosts
    

    This works fine if I'm using Linux. However, attempting to run vi on my phone when using Windows results in a borked vi screen with strange characters. I'm assuming this is because cmd doesn't support ANSI control characters.

    Is there any way to fix this (e.g., a cmd alternative that does the job)?

    • Chinmay Kanchi
      Chinmay Kanchi almost 12 years
      @MichaelHampton: This nearly works, but doesn't handle the <esc> key correctly, making it impossible to enter normal mode.
  • Chinmay Kanchi
    Chinmay Kanchi almost 12 years
    I don't really like cygwin, so I was hoping to avoid it. But it looks like the only viable choice here.
  • Idolon
    Idolon about 9 years
    I was not able to use ESC key in vi within Cygwin terminal
  • CODE-REaD
    CODE-REaD almost 8 years
    Only this answer solved my problem of attempting to use full screen applications through the adb listener under Windows 7. As far as I can tell, ConEmu does nothing to resolve the described problem. I also tried running adb shell under bash from Windows to no avail. I suspect the problem is with Windows' adb shell command itself. PuTTYTray implements its own connection to the adb listener, which apparently includes full screen terminal emulation where adb shell doesn't. Note: Above, you say use -d in the host field, but your snapshot shows -a as the option. I used -a successfull.
  • Idolon
    Idolon almost 8 years
    @Code-Read yes, -d and -a are equivalents when there is only one device connected. Regarding adb shell you are right as well. AFAIK, PuTTYTray is the only reliable way to use vi and other full screen apps on the Android device when connecting from Windows.
  • Wyatt Ward
    Wyatt Ward almost 8 years
    would be good but there's no adb for those and the normal windows ADB still sucks in a cygwin shell and MSYS.
  • frakman1
    frakman1 over 4 years
    What if your android is on WiFi. What option do you use then? I tried entering the IP address in the field where -a or -d etc are but it would crash as soon as I opened it.
  • Christophe
    Christophe over 3 years
    I still have garbage as you say in Windows Server 2012 R2 powershell terminal.