Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the '10.7: Use Terminal proxy icons in zsh' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.7: Use Terminal proxy icons in zsh
Authored by: usovalx on Aug 27, '11 09:10:45AM
Slighty more correct version is given below. This adds a guard aroud it (to prevent it sending crap if you use non-apple terminal) and uses $HOST instead of $HOSTNAME.
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 connections. Percent-escape spaces.
        local SEARCH=' '
        local REPLACE='%20'
        local PWD_URL="file://$HOST${PWD//$SEARCH/$REPLACE}"
        printf '\e]7;%s\a' "$PWD_URL"
    autoload add-zsh-hook
    add-zsh-hook chpwd update_terminal_cwd
Edited on Aug 27, '11 09:11:30AM by usovalx

[ Reply to This | # ]
10.7: Use Terminal proxy icons in zsh
Authored by: radiola on Aug 30, '11 10:30:00PM

@usovalx: Good catch on $HOSTNAME vs. $HOST for zsh. The basic proxy icon functionality works even without that, so I didn't notice it.

To be clear about the guard, that's only necessary for emacs's shell-mode. If you don't use it, you don't need to modify your .zshrc to add it. Too bad emacs doesn't set $TERM_PROGRAM on OS X -- that check does successfully keep the proxy-icon stuff out of the way of other terminal emulators and things like DTerm, which either don't set $TERM_PROGRAM or set it to something else.

I suppose that if you use zsh, you're practically bound to be using other weirdo stuff. :)

[ Reply to This | # ]