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

Re: Is there any possible way to automatically escape characters when executing an alias in zsh?



On 2021-09-11 03:28 PM, Peter Stephenson wrote:
On Sat, 2021-09-11 at 20:16 +0100, Peter Stephenson wrote:
accept-with-quote() {
  if [[ $BUFFER = 'tasn '* && $BUFFER != *\\* ]]; then
      BUFFER=${BUFFER//\'/\\\'}
  fi
}
zle -N zle-line-finish accept-quote

Very cool. It works! No idea what the zle command does but I'll google it. Thanks!

I have a number of aliases that begin with "ta" and "tm" that could benefit from this trick. I imagine I could turn the 'tasn '* bit into a regex test to check for a match.




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