Search code examples
zshzshrczsh-alias

Call a user defined function/alias with arguments in ZSH shell


I am using zsh for my shell and I have the following function defined in my ~/.zshrc to run custom commands inside my vagrant VM.

vt() {
    pushd ~/dev/vvv
    vagrant ssh -c $@
    popd
}

So to run the xdebug_on command inside my vagrant VM, I can just use the alias vt xdebug_on

I want to shorten this further and so I created another alias/function called vtxon

vtxon() {
    pushd ~/dev/vvv
    vagrant ssh -c xdebug_on
    popd
}

which is working, but I want to know if there is a way I can reuse vt alias/function vtxon instead of recreating everything.

Is it possible to do it?


Solution

  • Did you try a trivial

    vtxon() {
        vt xdebug_on
    }
    

    yet? Should work as long as the called function is known in the scope.