On Thu, 26 Aug 2021 at 16:06, Lars Ingebrigtsen wrote: > Augusto Stoffel writes: > >> Great! Another useful addition might be OSC 7 to report the working >> directory. This would be much simpler and more reliable than >> 'shell-dirtrack-mode', but needs a small configuration in the shell as >> well (append some stuff to $PS1 or $PROMPT_COMMAND) > > Yes, that sounds quite useful. > I've attached a patch to handle OSC 7, which is a protocol for the inferior process to tell the terminal about directory changes. This replaces the functionality of shell-dirtrack-mode and dirtrack-mode, perhaps in a less hacky way. Unfortunately, it needs a bit of configuration on the shell side too (no system will be preconfigured to emit OSCs to a dumb terminal). A slightly naive approach is run PROMPT_COMMAND='printf "\e]7;file://%s%s\e\\" "$HOSTNAME" "$PWD"' or add this to the bashrc file. On my system bash comes with a `__vte_osc7' function which is similar but slightly more robust (it urlencodes the PWD). (I've also removed some borderline paranoid checks on the variable `comint-last-output-start' which I had copied from ansi-color. On closer inspection, those checks are working around a bug in gdb-mi. Good opportunity to check if that bug was fixed.)