What does update_terminal_cwd do in the terminal of OS X
I am puzzled by it for quite some while now. In $PROMPT_COMMAND
of the bash in OS X, there is a command called update_terminal_cwd
. I am sure it's not a bash built in, and most likely only exists in OS X. But I don't know what exactly it does. Anyone knows?
Solution 1:
It updates the prompt to echo the Current Working Directory (CWD) and is defined in /etc/bashrc
:
update_terminal_cwd() {
# Identify the directory using a "file:" scheme URL,
# including the host name to disambiguate local vs.
# remote connections. Percent-escape spaces.
local SEARCH=' '
local REPLACE='%20'
local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}"
printf '\e]7;%s\a' "$PWD_URL"
}