2

I'm trying to alias eclipse to execute eclipse -data $(pwd). However, for some reason adding this to my zshrc doesn't work:

alias eclipse="eclipse -data $(pwd)"

I can't seem to find the correct syntax - can someone help me out?

chintanparikh
  • 1,632
  • 6
  • 22
  • 36

2 Answers2

5

I don't think you can use parameters in an alias (that's what other posts seem to indicate). You can instead define a function:

function eclipse () {
     eclipse -data "$(pwd)"
}

Of course, if you do that, running eclipse will give you:

eclipse: maximum nested function level reached

That's because once you define the function named eclipse that masks the external command, resulting in an infinite recursion loop.

Instead, you can use command to tell zsh to ignore any aliases or functions named eclipse:

function eclipse () {
     command eclipse -data "$(pwd)"
}
Community
  • 1
  • 1
cyfur01
  • 3,262
  • 1
  • 34
  • 38
0

In that case you could use `command` for executing pwd:

alias eclipse="eclipse -data `pwd`"
Microfed
  • 2,832
  • 22
  • 25