a9e97e5d2da90cf3e2b4575888fe585972ebcc74

Author
Andrew Janke <janke@pobox.com>
Committer
Andrew Janke <janke@pobox.com>
Date

Message

Remove terminalapp plugin and fold its implementation in to lib/termsupport.zsh. Replaces the redundant Terminal.app support that was recently added to termsupport.

Diff

 1diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
 2index e1c2e2f93a3b376a02180d21cdddf01f0bcdcb29..da74dfdba457e5627e67eba91c4f3ee335b41da3 100644
 3--- a/lib/termsupport.zsh
 4+++ b/lib/termsupport.zsh
 5@@ -53,14 +53,37 @@ precmd_functions+=(omz_termsupport_precmd)
 6 preexec_functions+=(omz_termsupport_preexec)
 7 
 8 
 9-# Runs before showing the prompt, to update the current directory in Terminal.app
10-function omz_termsupport_cwd {
11-  # Notify Terminal.app of current directory using undocumented OSC sequence
12-  # found in OS X 10.9 and 10.10's /etc/bashrc
13-  if [[ $TERM_PROGRAM == Apple_Terminal ]] && [[ -z $INSIDE_EMACS ]]; then
14-    local PWD_URL="file://$HOSTNAME${PWD// /%20}"
15-    printf '\e]7;%s\a' "$PWD_URL"
16-  fi
17-}
18+# Keep Apple Terminal.app's current working directory updated
19+# Based on this answer: http://superuser.com/a/315029
20+
21+if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
22+  # Emits the control sequence to notify Terminal.app of the cwd
23+  function update_terminalapp_cwd() {
24+        # Identify the directory using a "file:" scheme URL, including
25+        # the host name to disambiguate local vs. remote paths.
26+
27+        # Percent-encode the pathname.
28+        local URL_PATH=''
29+        {
30+            # Use LANG=C to process text byte-by-byte.
31+            local i ch hexch LANG=C
32+            for ((i = 1; i <= ${#PWD}; ++i)); do
33+                ch="$PWD[i]"
34+                if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then
35+                    URL_PATH+="$ch"
36+                else
37+                    hexch=$(printf "%02X" "'$ch")
38+                    URL_PATH+="%$hexch"
39+                fi
40+            done
41+        }
42+
43+        local PWD_URL="file://$HOST$URL_PATH"
44+        printf '\e]7;%s\a' "$PWD_URL"
45+    }
46 
47-precmd_functions+=(omz_termsupport_cwd)
48+    # Use a precmd hook instead of a chpwd hook to avoid contaminating output
49+    precmd_functions+=(update_terminalapp_cwd)
50+    # Run once to get initial cwd set
51+    update_terminalapp_cwd
52+fi
53diff --git a/plugins/terminalapp/terminalapp.plugin.zsh b/plugins/terminalapp/terminalapp.plugin.zsh
54deleted file mode 100644
55index 6e47ee188db466f713b1203ae4918a8ddd6d8982..0000000000000000000000000000000000000000
56--- a/plugins/terminalapp/terminalapp.plugin.zsh
57+++ /dev/null
58@@ -1,39 +0,0 @@
59-# Set Apple Terminal.app resume directory
60-# based on this answer: http://superuser.com/a/315029
61-# 2012-10-26: (javageek) Changed code using the updated answer
62-
63-# Tell the terminal about the working directory whenever it changes.
64-if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
65-  update_terminal_cwd() {
66-        # Identify the directory using a "file:" scheme URL, including
67-        # the host name to disambiguate local vs. remote paths.
68-
69-        # Percent-encode the pathname.
70-        local URL_PATH=''
71-        {
72-            # Use LANG=C to process text byte-by-byte.
73-            local i ch hexch LANG=C
74-            for ((i = 1; i <= ${#PWD}; ++i)); do
75-                ch="$PWD[i]"
76-                if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then
77-                    URL_PATH+="$ch"
78-                else
79-                    hexch=$(printf "%02X" "'$ch")
80-                    URL_PATH+="%$hexch"
81-                fi
82-            done
83-        }
84-
85-        local PWD_URL="file://$HOST$URL_PATH"
86-        #echo "$PWD_URL"        # testing
87-        printf '\e]7;%s\a' "$PWD_URL"
88-    }
89-
90-    # Register the function so it is called whenever the working
91-    # directory changes.
92-    autoload add-zsh-hook
93-    add-zsh-hook precmd update_terminal_cwd
94-
95-    # Tell the terminal about the initial directory.
96-    update_terminal_cwd
97-fi