Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Escape prompt expansion arguments in precmd before setting title. #570

Closed
wants to merge 1 commit into from

2 participants

@eatnumber1

The arguments passed to precmd that are used to set the title ($2 and $CMD) were not properly being escaped for prompt expansion. Fixes issue #342.

@eatnumber1 eatnumber1 Escape prompt expansion arguments in precmd before setting title.
The arguments passed to precmd that are used to set the title ($2 and
$CMD) were not properly being escaped for prompt expansion. Fixes
issue #342.
9634d69
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 24, 2011
  1. @eatnumber1

    Escape prompt expansion arguments in precmd before setting title.

    eatnumber1 authored
    The arguments passed to precmd that are used to set the title ($2 and
    $CMD) were not properly being escaped for prompt expansion. Fixes
    issue #342.
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 4 deletions.
  1. +12 −4 lib/termsupport.zsh
View
16 lib/termsupport.zsh
@@ -4,11 +4,16 @@
#Limited support for Apple Terminal (Terminal can't set window or tab separately)
function title {
[ "$DISABLE_AUTO_TITLE" != "true" ] || return
+ local e1="$1" e2="$2"
+ if [[ "$TITLE_NO_ESCAPE" != 1 ]]; then
+ e1="$1:q"
+ e2="$1:q"
+ fi
if [[ "$TERM" == screen* ]]; then
- print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars
+ print -Pn "\ek$e1\e\\" #set screen hardstatus, usually truncated at 20 chars
elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
- print -Pn "\e]2;$2:q\a" #set window name
- print -Pn "\e]1;$1:q\a" #set icon (=tab) name (will override window name on broken terminal)
+ print -Pn "\e]2;$e2\a" #set window name
+ print -Pn "\e]1;$e1\a" #set icon (=tab) name (will override window name on broken terminal)
fi
}
@@ -25,5 +30,8 @@ function preexec {
emulate -L zsh
setopt extended_glob
local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
- title "$CMD" "%100>...>$2%<<"
+ local psvar
+ psvar[1]="$CMD"
+ psvar[2]="$2"
+ TITLE_NO_ESCAPE=1 title "%1v" "%100>...>%2v%<<"
}
Something went wrong with that request. Please try again.