...
- The terminal title message code: the message between the \033(\e)]0; and \007(\a) codes
- A setting where a command is executed every time new prompt is displayed.
The PROMPT_COMMAND environment variable is or PS1 environment variables are used in BASH
Basically, a terminal emulator cannot know in which directory a user is working. But there is a way in which the terminal can determine the working directory under a restricted condition.
...