On Mon, Aug 21, 2017 at 11:45 AM, Michael Albinus wrote: > > Well, we have `tramp-sh-extra-args' for ages. But this doesn't work > usually, because I don't know a bullet-proof way to detect a bash shell > prior invocation, unless "*bash" is called. > *nod* The best I can think of, since we already have the "outer" shell, would be to invoke `/bin/sh --version -c exit`, which should work on any basic posix shell, and will emit a bash version string for bash, then wait for the prompt, and scan the output for the appropriate version data. Let me contemplate about. With Emacs 26 / Tramp 2.3, we have > connection-local variables. Maybe we could use it for your case. > FWIW, I already extend `tramp-actions-before-shell`, so something similarly low level would be fine by me, to handle the custom stuff. However, `ansi-color-filter-region` and friends from the shipped ANSI SGR->face handling library can strip all control sequences out of a region, or string, and might be useful here; that would allow TRAMP to become insensitive to ANSI control codes injected anywhere into the output, which will also fix the next time a shell decides to add some additional terminal integration like bracketed paste mode. If you want to apply this to streaming output, because that will rewrite the buffer fragment with a smaller number of characters in the presence of control codes, throw a marker at your endpoint, and retrieve the position after the stripping, to avoid getting confused about the new offset.