1diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
2index ef9f0e5f1f6050ab2a792ef5ad06e1ad74807842..7cb3791e688fb66456cad0596d3f28e2e7491a31 100644
3--- a/lib/termsupport.zsh
4+++ b/lib/termsupport.zsh
5@@ -63,33 +63,31 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
6 # Outputs the encoded string on stdout
7 # Returns nonzero if encoding failed
8 function _omz_urlencode() {
9+ local str=$1
10 local url_str=''
11- {
12- local str=$1
13-
14- # URLs must use UTF-8 encoding; convert if required
15- local encoding=${LC_CTYPE/*./}
16- if [[ -n $encoding && $encoding != UTF-8 ]]; then
17- str=$(iconv -f $encoding -t UTF-8)
18- if [[ $? != 0 ]]; then
19- echo "Error converting string from $encoding to UTF-8" >&2
20- return 1
21- fi
22- fi
2324- # Use LC_CTYPE=C to process text byte-by-byte
25- local i ch hexch LC_CTYPE=C
26- for ((i = 1; i <= ${#str}; ++i)); do
27- ch="$str[i]"
28- if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then
29- url_str+="$ch"
30- else
31- hexch=$(printf "%02X" "'$ch")
32- url_str+="%$hexch"
33- fi
34- done
35- echo $url_str
36- }
37+ # URLs must use UTF-8 encoding; convert if required
38+ local encoding=${LC_CTYPE/*./}
39+ if [[ -n $encoding && $encoding != UTF-8 ]]; then
40+ str=$(iconv -f $encoding -t UTF-8)
41+ if [[ $? != 0 ]]; then
42+ echo "Error converting string from $encoding to UTF-8" >&2
43+ return 1
44+ fi
45+ fi
46+
47+ # Use LC_CTYPE=C to process text byte-by-byte
48+ local i ch hexch LC_CTYPE=C
49+ for ((i = 1; i <= ${#str}; ++i)); do
50+ ch="$str[i]"
51+ if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then
52+ url_str+="$ch"
53+ else
54+ hexch=$(printf "%02X" "'$ch")
55+ url_str+="%$hexch"
56+ fi
57+ done
58+ echo $url_str
59 }
6061 # Emits the control sequence to notify Terminal.app of the cwd