Function: ansi-osc-directory-tracker

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

Signature

(ansi-osc-directory-tracker _ TEXT)

Documentation

Update default-directory from OSC 7 escape sequences.

This function is intended to be included as an element of the list that is the value of ansi-osc-handlers. You should arrange for your shell to print the appropriate escape sequence at each prompt, such as 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).

Aliases

comint-osc-directory-tracker (obsolete since 30.1)

Source Code

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

This function is intended to be included as an element of the
list that is the value of `ansi-osc-handlers'.  You should arrange
for your shell to print the appropriate escape sequence at each prompt,
such as 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))
                   ;; Use `downcase' to match `url-generic-parse-url' behavior
                   (string= (url-host url) (downcase (system-name)))))
      (ignore-errors
        (cd-absolute (url-unhex-string (url-filename url)))))))