You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
__fish_urlencode wide character output confuses OS X Terminal.app #2598
If I make a directory called, for example, ~/ok-太空步教学视频 and change into it, the proxy icon in Terminal.app will not be resolvable, because of the file:// URI produced on interactive terminals.
It is outputting for example %592a where bash is outputting %E5%A4%AA which works.
I can easily pick out in the inspector under Directory the difference between a working proxy icon and these non-working ones. Feeding the ones fish makes into open(1) produces an error.
Bash uses this function from /etc/bashrc_Apple_Terminal:
# Working Directory## Tell the terminal about the current working directory at each prompt.if [ -z"$INSIDE_EMACS" ];thenupdate_terminal_cwd() {
# Identify the directory using a "file:" scheme URL, including# the host name to disambiguate local vs. remote paths.# Percent-encode the pathname.local url_path=''
{
# Use LC_CTYPE=C to process text byte-by-byte. Ensure that# LC_ALL isn't set, so it doesn't interfere.local i ch hexch LC_CTYPE=C LC_ALL=
for((i =0; i <${#PWD}; ++i));do
ch="${PWD:i:1}"if [[ "$ch"=~ [/._~A-Za-z0-9-] ]];then
url_path+="$ch"elseprintf -v hexch "%02X""'$ch"# printf treats values greater than 127 as# negative and pads with "FF", so truncate.
url_path+="%${hexch: -2:2}"fidone
}
printf'\e]7;%s\a'"file://$HOSTNAME$url_path"
}
PROMPT_COMMAND="update_terminal_cwd${PROMPT_COMMAND:+; $PROMPT_COMMAND}"fi
I tried to imitate that script using fish's new string functions and the printf it has but cannot get fish's printf to do the same conversion here no matter what my LC_ALL, etc.
Whoops. While I don't get those warnings, I just actually tried cd'ing into the directory with my code on a fresh HEAD and it doesn't work to produce resolvable-to-Terminal.app or open()able URIs either... I think while trying random stuff I probably did something to mess up my locale across sessions. Your fix produces working proxy icons after cd'ing. Alternatively the same LC_ALL allowed me to use the builtin printf versus /usr/bin/printf the way I wanted to (unless I'm crazy again). Thanks!
function __fish_urlencode --description"URL-encode stdin"set-l IFS ''set-l LC_ALL C
whileread--array--local chars
iftest (count$chars) -gt 0
for char in$charsiftest (string match -r-q'[-_/\w.]'$char) -eq 0
printf$charelseprintf'%%%02X'"'$char"endendendendend
Activity
floam commentedon Dec 11, 2015
For what it's worth, this fixes OS X. Maybe not the best way.
floam commentedon Dec 12, 2015
Whoops. While I don't get those warnings, I just actually tried cd'ing into the directory with my code on a fresh HEAD and it doesn't work to produce resolvable-to-Terminal.app or open()able URIs either... I think while trying random stuff I probably did something to mess up my locale across sessions. Your fix produces working proxy icons after cd'ing. Alternatively the same LC_ALL allowed me to use the builtin printf versus /usr/bin/printf the way I wanted to (unless I'm crazy again). Thanks!