help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tramp and adb, strange escape codes in dired


From: Michael Albinus
Subject: Re: tramp and adb, strange escape codes in dired
Date: Thu, 11 Jun 2020 19:55:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

<tomas@tuxteam.de> writes:

Hi,

> On Thu, Jun 11, 2020 at 03:55:50PM +0200, Giovanni Biscuolo wrote:
>> Hello,
>>
>> I'm using Emacs 26.3 and adb 7.1.2_r36 [1], both installed via Guix on a
>> foreign distro (Debian 10)
>>
>> I'm trying to use adb via tramp (I'd love to be able to browse my phone
>> filesystem in Emacs) for the first time and I get a strange dired
>> buffer:
>>
>> --8<---------------cut here---------------start------------->8---
>>
>>   /adb::/storage:
>>   total 13
>>   drwxr-xr-x  1 root root          80 05-31 13:04 [1;34m.[0m
>>   drwxr-xr-x  1 root root          4k 2009-01-01  [1;34m..[0m
>>   drwx--x--x  1 root sdcard_rw     4k 05-31 13:04 [1;34memulated[0m
>
> [...]
>
> FWIW, this looks a lot like escape sequences setting the display to
> bold (ESC[1;34m) before and resetting it (ESC[0m) after the file
> name.
>
> I don't really know what there is at the other end, but convincing
> it that you have a very dumb terminal might help.

Tramp tries to find a proper `ls' command which suppresses escape
sequences. The following defun does it:

--8<---------------cut here---------------start------------->8---
(defun tramp-adb-get-ls-command (vec)
  "Determine `ls' command and its arguments."
  (with-tramp-connection-property vec "ls"
    (tramp-message vec 5 "Finding a suitable `ls' command")
    (cond
     ;; Support Android derived systems where "ls" command is provided
     ;; by GNU Coreutils. Force "ls" to print one column and set
     ;; time-style to imitate other "ls" flavors.
     ((tramp-adb-send-command-and-check
       vec "ls --time-style=long-iso /dev/null")
      "ls -1 --time-style=long-iso")
     ;; Can't disable coloring explicitly for toybox ls command.  We
     ;; also must force "ls" to print just one column.
     ((tramp-adb-send-command-and-check vec "toybox") "ls -1")
     ;; On CyanogenMod based system BusyBox is used and "ls" output
     ;; coloring is enabled by default.  So we try to disable it when
     ;; possible.
     ((tramp-adb-send-command-and-check vec "ls --color=never -al /dev/null")
      "ls --color=never")
     (t "ls"))))
--8<---------------cut here---------------end--------------->8---

Obviously, in this case we need more. Giovanni, which Android version
are you running? And can you check via "adb shell", which kind of ls is
installed there?

(Personally, I run a Galaxy S6 with Android 7. I fear it is much too old
for local tests.)

> Cheers
> -- t

Best regards, Michael.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]