update_terminal_cwd demystified please?
from Terminal.app v2.6.1 (OS X 10.11), under Preferences/Profiles/Window, there is highlighted text "Escape sequence..." which says:


  The working directory and location of the current document may be set
  using the Operating System Command (OSC) escape sequence:
  
  ESC ] Ps ; Pt BEL
  
  The parameter Ps is either 6 (document) or 7 (working directory) and
  Pt is a “file:” URL. The URL should include a hostname to disambiguate
  local and remote paths, and characters must be percent-encoded as
  appropriate.
  
  When both the working directory and document are set only the document
  is displayed.


also, from Preferences/Profiles/Tab:


  Window and tab titles may be set using the Operating System Command
  (OSC) escape sequence:
  
  ESC ] Ps ; Pt BEL
  
  The parameter Ps is either 1 (tab title—aka “icon title”) or 2 (window
  title) and Pt is the title text.
  
  A custom window title will be displayed within the tab title (along
  with the other selected items) if there is no custom tab title.
  
  The following example bash command sets the tab title to “My Tab”:
  
  printf '\e]1;%s\a' 'My Tab'