Following Mark Twain’s often-quoted advice to “write what you know,” comedian Pete Holmes turns the clock back a decade to delve into his own past as a newbie standup in the HBO series Crashing. That means mining his awkward breakup with his cheating wife and couch-surfing adventures with more established comics for laughs.

Premiering this Sunday at 10:30/9:30c, the eight-episode series was co-created with Judd Apatow and features real-life stand-ups Artie Lange, T.J. Miller, Dave Attell, Hannibal Burress, and Sarah Silverman as themselves. Holmes, who hosted an eponymous talk show on TBS, did audience warm-up for The Daily Show and hosts the podcast You Made it Weird, is currently wrapping up his latest stand-up tour.

So we asked him about his dues-paying days in the comedy clubs, what he learned from his divorce and, of course, the worst heckling he’s ever received.

“From my divorce I learned that just because you’re nice and sweet, it doesn’t mean you’re giving someone what they need. I don’t mean sex. You need to be fully available to the other person emotionally, and in every way.”

Is the Pete Holmes in Crashing the guy you were when you were starting out in comedy?
Exactly—he’s a less experienced and more innocent and naïve guy. It’s fun to play because you get to take the things that make you a grownup and put them aside and be childish for a while.

How much else is autobiographical?
The feeling is 100 percent true, but what happens is fictionalized. The characters and situations have been changed to be funnier and more interesting. I was raised religious, I did get married when I was 22 and she did leave me when I was 28 for another man. That was almost 10 years ago. I did mine that experience, some of the emotional truths. Judd Apatow is very good at taking a real experience and turning it into a show you would like to watch. We’re excited to be doing a show that has some heart and tells some of the secrets about what it’s like to start as a standup in New York.

Did you really crash on comedian friends’ couches?
There was some of that. People like T.J. Miller and John Mulaney and Nick Kroll really stepped up to the plate when my wife left and helped me get back on my feet. T.J. was filming a movie in Pittsburgh and he flew me there and put me up in his hotel for four days.

Your wife cheating on you is fodder for comedy on the show, but what did you learn from the experience?
I learned that just because you’re nice and sweet, it doesn’t mean you’re giving someone what they need. I don’t mean sex. You need to be fully available to the other person emotionally, and in every way.

Have you gotten better at that?
I sure have. I was very deliberate about that. There was a lot of therapy, some trial and error. I’ve had four or five girlfriends since then and I’ve grown up in a lot of ways.

What advice would you give guys going through a breakup?
Don’t demonize the other person. Cop to your involvement in it. “How was I responsible for it?” I thought I was a good husband, but in truth there were a lot of ways in which I was not available to her. Don’t make your partner a villain.

“I think the worst heckle I ever got, what made it so bad was how elegant it was. Someone yelled ‘Next!’ It got such a huge laugh and I didn’t know what to do.”

Were you the class clown when you were a kid?
I was the best friend of the class clowns. I was very interested in studying their moves and understanding where their humor was coming from. When I was really young I was kind of a hammy kid. I liked getting attention and I’d get in trouble sometimes. But I don’t think I learned how to become funny until high school. It took a while to figure out how to turn that hyperactive energy into something people would actually laugh at. I thought I was going to be a youth pastor for most of my life. I’d go up on stage at our youth group and do an impression of my youth pastor, and I used to do impressions of comedians. At some point I just realized I just wanted to be in front of people and making them happy.

How hard was it to get started?
It’s difficult because everyone thinks they’re funny. It’s like coming out of the comedy closet, when you finally summon the courage to tell your friends that you want to be a comedian. It takes some bravery to go pro at something we’re all doing. The best advice I got was put the idea of getting paid out of your head, and then it’ll happen. I used to hand out flyers for four or five hours to perform for three people on a Tuesday and I’d walk home and my feet wouldn’t touch the ground. I was so thrilled to be in Manhattan, doing comedy for no money, doing open mikes at a Thai restaurant at 6 o’clock. The problem with open mikes is that it’s not a real audience. It’s all other comedians waiting to perform.

Do you remember the really awful gigs, when you bombed and got heckled?
Oh yeah, those never go away. I think the worst heckle I ever got, what made it so bad was how elegant it was. Someone yelled “Next!” It got such a huge laugh and I didn’t know what to do.

Did you ever lie to get a job?
The only lie I’ve told to get a gig was that I was ready to do it. I said I had 30 minutes of material and had 20 minutes, thinking in a week I could write 10 more minutes. It’s harder than it sounds.

What’s on your to-do list now? Movies?
I don’t know. I’m open to all of it. I’m interested in trying to write a book. I hope Crashing will go for many seasons. But it’s really a year-round job. If we get some time off I want to sit on the porch with my dog, not do a movie!

Photo: Macall B. Polay/HBO