What happens when you accidentally tear a favorite T-shirt or pair of jeans? Sure, some of us will repair it, but most people will just throw it out.

Imagine if there was a way for torn fabric to repair itself.

It's an idea that researchers at Pennsylvania State University have been working on for a few years--and it's now come to fruition.

The team used bacteria and yeast to create a biodegradable liquid material that can help fabric to quickly bind to itself.

It's a simple process. You put a few drops of the liquid on the tear, apply warm water and press the edges together for a minute. The fabric reattaches and essentially self repairs, said Melik Demirel, a professor of engineering science and mechanics at Penn State.

The liquid can work with fabric in a couple different ways.

Textile manufacturers can coat already-made fabric with the liquid. The coated fabric then has a self-repair ability automatically built into it, said Demirel, who led the research.

Additionally, cloth can be made using fiber that's actually produced with the protein. This way the cloth will inherently have the ability to self-repair with the application of pressure and water.

Related: Yes, you can 3D print with beer, coffee and hemp

The liquid, which Demirel still hasn't named, has similar properties and structure to protein found in human hair, nails and squid tentacles.

Yes, squid tentacles. Demirel said they were surprised to discover that the protein from squid had self-repairing qualities.

"Squid is a limited resource. So we needed to replicate this unique property found in squid protein using biotechnology and other substances," he said.

Over the last year, Demirel's group developed the liquid and tested it on commonly worn fabrics like cotton, wool and polyester.

Related: We buy too many clothes and we pay too little for them

He found that the liquid didn't alter the quality of the fabric, and that it withstood a wash in a machine.

"Science happens in small steps," said Demirel. "The next step would be to see if clothes can self-repair when we pour the liquid into a washing machine, like you would a detergent, and apply water and heat."

How IBM is making plastic less toxic

Demirel said he's excited about the commercial application of the liquid.

"It could help improve protective clothing worn by soldiers, medical staff, even farmers," he said. Demirel's research was partly funded by the Office of Naval Research and the Army Research Office.

It could also change consumer habits and help reduce clothing waste.

"Discarded clothing is a major global problem," he said. "Maybe this is a way to improve the longevity of clothes we wear."