Zsh – alias -s with parameter

aliaszsh

In zsh, I can specify default program to open which file extension like alias -s {mkv,mpg}='mplayer' . I runs fine but what I really want is to run mplayer <filename> & so it won't produce technical stuffs and 'stealing' my current shell session.

How can I make this happen ?

Thanks for reading 🙂

Best Answer

You either provide a wrapper script or a function doing what you need, e.g:

background() {
  "$@" &
}

and use the function/script instead:

alias -s {mkv,mpg}='background mplayer'
Related Question