Search code examples
zshzshrc

Is there a zsh equivalent to the function-in-alias idiom?


After many years, I'm giving zsh a try. I have

alias rsync='rsync -av --progress --stats --human-readable'

and also a lot of aliases like this in my bash .profile

alias workin='function _workin(){ rsync -avE --progress --stats --human-readable -e ssh me@$1:/there/ /here; };_workin'

I've been unable to figure out how to get this to work in zsh. I keep getting errors of the sort 'no matches found'. Any ideas? Thanks in advance!


Solution

  • The solution, in bash and zsh, is to dispense with the alias altogether.

    workin () {
      rsync -avE --progress --stats --human-readable -e ssh me@"$1":/there/ /here
    }
    

    (Whether or not you need to quote $1 depends on what settings you are using; zsh is somewhat too configurable. But, it won't hurt to quote it, so I'll do so here.)