Ed Begley Jr., current environmental crusader and former star of ’80s hit “St. Elsewhere,” had a rude encounter with a homeless dude in LA over the weekend.

Spies said Begley was spotted outside a CVS, where he was giving a homeless guy some dough.

The homeless man quipped, “So . . . you’re not on TV anymore.” The actor replied, “No,” before walking away.

“Only in [bleeping] LA,” summed up a spy.

Begley, who’s competing with Bill Nye to see who can have the lowest carbon footprint, has had recurring roles on “CSI: Miami” and “Arrested Development.”