Xana/ xana2/ 2007/ 10/ 04
Having your caret and eating it too

Let's say you're a French person who has EXTENDED_GLOB on and types HEAD^ all the time, but can't be bothered to type a backslash before the caret. Personally, I have no problem typing HEAD\^, but I probably only do that twice a day.

Here are a few/several/many (depending on how you count) “solutions”. They all have their downsides. Finding out their side effects is an exercise for the reader.

Number one: setopt noextendedglob

Number two: setopt nonomatch

Number three: alias git='noglob git'

Number four: custom ZLE widget:

accept_line_with_headcaret () {
  if  ${BUFFER} = git*HEAD\^* ; then
    BUFFER="${BUFFER//HEAD\^/HEAD\\^}"
  fi

  zle .accept-line
}
zle -N accept-line accept_line_with_headcaret

I'll just keep hitting the backslash key.

Posted Thu 04 Oct 2007 03:17:15 PM EDT Tags: 04