Plugin support copied from gpm

See https://github.com/pote/gpm/blob/c4fb200881fdfd5681b98054dd25ab041f54e229/bin/gpm#L85-L99
Merge pull request #14 from michaelmaltese/patch-1

Plugin support copied from gpm