Function: comint-osc-directory-tracker

comint-osc-directory-tracker is a byte-compiled function defined in comint.el.gz.

Signature

(comint-osc-directory-tracker _ TEXT)

Documentation

Update default-directory from OSC 7 escape sequences.

This function is intended to be included as an entry of comint-osc-handlers. You should moreover arrange for your shell to print the appropriate escape sequence at each prompt, say with the following command:

    printf "\\e]7;file://%s%s\\e\\\\" "$HOSTNAME" "$PWD"

This functionality serves as an alternative to dirtrack-mode(var)/dirtrack-mode(fun) and shell-dirtrack-mode(var)/shell-dirtrack-mode(fun).

Source Code

;; Defined in /usr/src/emacs/lisp/comint.el.gz
(defun comint-osc-directory-tracker (_ text)
  "Update `default-directory' from OSC 7 escape sequences.

This function is intended to be included as an entry of
`comint-osc-handlers'.  You should moreover arrange for your
shell to print the appropriate escape sequence at each prompt,
say with the following command:

    printf \"\\e]7;file://%s%s\\e\\\\\" \"$HOSTNAME\" \"$PWD\"

This functionality serves as an alternative to `dirtrack-mode'
and `shell-dirtrack-mode'."
  (let ((url (url-generic-parse-url text)))
    (when (and (string= (url-type url) "file")
               (or (null (url-host url))
                   (string= (url-host url) (system-name))))
      (ignore-errors
        (cd-absolute (url-unhex-string (url-filename url)))))))