Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: what is the effect of a percentage sign (%) as last character on the command line




I presume you had that somewhere interesting like inside your precmd
or preexec function?  Just having it "in .zshrc" wouldn't affect any
command except possibly the very first one.
Yes, sorry , my snippet was too short:


git_info() {
  ref=$(git symbolic-ref -q HEAD 2>/dev/null)
  ref=${ref#refs/heads}
  echo ${ref:+"${GREEN}[$ref]${WHITE}"}

EXITCODE='%(?..(%?%))'
precmd () {
  PS1="%m%F{red}${EXITCODE}%f%# "
  RPROMPT="$(git_info)%30<..<%/"

  case $TERM in
    (xterm*|rxvt|mrxvt)
    print -Pn "\e]0;%n@%m: $1\a"
    ;;
  esac
}

And to follow your script hint ( with the erronous precmd version above ) :

$ date%
$(127)
$ script zsh.out
Script started, file is zsh.out
$ date%
zsh: command not found: date%
$ <CTRL-D>
Script done, file is zsh.out
$ cat zsh.out
Script started on Sun 24 Jan 2010 10:42:39 AM CET
$ date%
zsh: command not found: date%
$(127)

Script done on Sun 24 Jan 2010 10:43:06 AM CET
$ date%
$(127)

So apparently , the script program swallows the "dangling" control character and the shell behaves as expected ...

Peter



Messages sorted by: Reverse Date, Date, Thread, Author