Terminal.app: escape codes for working directory and document?
1
vote
1
answer
96
views
Does anyone know what the escape sequences are to show "working directory" and "document" in Mac OSX
ref: my copyright fair use
Here's an example of output from "urlencode" I'm passing in the escape sequence:
\033]7;file%3a%2f%2flocalhost%2f%2fUsers%2fusername\007
Terminal.app
? I'm trying the method to urlencode a URL and it's not working with zsh.
I have a graphic of the dialog in Preferences below.
So far, I've only been able to get the following working which allows a drop down to the current path on the left of the top bar:
_PWD=$(echo $PWD| sed "s;$HOME;~;")
__SHELL="zsh"
printf "\033]0;$USER@$HOSTNAME '${_PWD}' ${__SHELL}\007"
I'm not sure why above works, however if I remove the escape code the drop down isn't displayed anymore. I tried the following per the directions to percent "urlencode" a URL to a file, but it's not working:
PWD_URL="$(urlencode file:$PWD)"
printf "\033]6;%s\007" ${PWD_URL}
printf "\033]7;%s\007" ${PWD_URL}
urlencode () {
string=$1
while [ -n "$string" ]; do
tail=${string#?}
head=${string%$tail}
case $head in
[-._~0-9A-Za-z]) printf %c "$head";;
*) printf %%%02x "'$head"
esac
string=$tail
done
echo
}
I have "Working directory or document" and "Path" enabled above escape sequences.

Asked by atod
(77 rep)
Jan 31, 2025, 02:48 AM
Last activity: Jan 31, 2025, 06:59 PM
Last activity: Jan 31, 2025, 06:59 PM