Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
4d8fe543
Commit
4d8fe543
authored
Oct 26, 2012
by
Guillermo Castro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated code from answer URL
parent
c2ae9e09
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
8 deletions
+35
-8
terminalapp.plugin.zsh
plugins/terminalapp/terminalapp.plugin.zsh
+35
-8
No files found.
plugins/terminalapp/terminalapp.plugin.zsh
View file @
4d8fe543
# Set Apple Terminal.app resume directory
# based on this answer: http://superuser.com/a/315029
# 2012-10-26: (javageek) Changed code using the updated answer
function
chpwd
{
local
SEARCH
=
' '
local
REPLACE
=
'%20'
local
PWD_URL
=
"file://
$HOSTNAME
${
PWD
//
$SEARCH
/
$REPLACE
}
"
printf
'\e]7;%s\a'
"
$PWD_URL
"
}
# Tell the terminal about the working directory whenever it changes.
if
[[
"
$TERM_PROGRAM
"
==
"Apple_Terminal"
]]
&&
[[
-z
"
$INSIDE_EMACS
"
]]
;
then
update_terminal_cwd
()
{
# Identify the directory using a "file:" scheme URL, including
# the host name to disambiguate local vs. remote paths.
chpwd
\ No newline at end of file
# Percent-encode the pathname.
local
URL_PATH
=
''
{
# Use LANG=C to process text byte-by-byte.
local
i ch hexch
LANG
=
C
for
((
i
=
1
;
i <
=
${#
PWD
}
;
++i
))
;
do
ch
=
"
$PWD
[i]"
if
[[
"
$ch
"
=
~
[
/._~A-Za-z0-9-]
]]
;
then
URL_PATH+
=
"
$ch
"
else
hexch
=
$(
printf
"%02X"
"'
$ch
"
)
URL_PATH+
=
"%
$hexch
"
fi
done
}
local
PWD_URL
=
"file://
$HOST$URL_PATH
"
#echo "$PWD_URL" # testing
printf
'\e]7;%s\a'
"
$PWD_URL
"
}
# Register the function so it is called whenever the working
# directory changes.
autoload add-zsh-hook
add-zsh-hook chpwd update_terminal_cwd
# Tell the terminal about the initial directory.
update_terminal_cwd
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment