Plugin support copied from gpm

See https://github.com/pote/gpm/blob/c4fb200881fdfd5681b98054dd25ab041f54e229/bin/gpm#L85-L99