Skip to content

Instantly share code, notes, and snippets.

@indirect
Created July 30, 2011 02:53
Show Gist options
  • Save indirect/1115141 to your computer and use it in GitHub Desktop.
Save indirect/1115141 to your computer and use it in GitHub Desktop.
set PWD in Lion Terminal.app from screen
# Screen-compatible update_terminal_cwd()
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}"
# Include the escapes needed for screen to forward to Terminal.app
printf '\eP\e]7;%s\a\e\\' "$PWD_URL"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment