In this paper, we investigate a generalized nonautonomous nonlinear equation, which describes the ultrashort optical pulse propagating in a nonlinear inhomogeneous fiber. Under certain integrable constraints, bilinear forms, bright one- and two-soliton solutions are obtained. Via certain transformation, we investigate the properties of the solitons with the first-order dispersion parameter sigma(1)(x, t), second-order dispersion parameter sigma(2)(x, t), third-order dispersion parameter sigma(3)(x, t), phase modulation and gain (loss) v(x, t). Soliton propagation and collision are graphically presented and analyzed: One soliton is shown to maintain its amplitude and width during the propagation. When we choose sigma(1)(x, t), sigma(2)(x, t) and sigma(3)(x, t) differently, travelling direction of the soliton is found to alter. v(x, t) is observed to affect the amplitude of the soliton. Head-on collision between the two solitons is presented with sigma(1)(x, t), sigma(2)(x, t), sigma(3)(x, t) and v(x, t) as the constants, and solitons' amplitudes are the same before and after the collision. When sigma(1)(x, t), sigma(2)(x, t) and sigma(3)(x, t) are chosen as certain functions, the solitons' traveling directions change during the collision. v(x, t) can influence the amplitudes of the two solitons. (C) 2016 Elsevier B.V. All rights reserved.