On a linear Gaussian channel with intersymbol interference (ISI), trellis precoding is a method that achieves the equalization performance of Tomlinson-Harashima (TH) precoding, the coding gain of any known lattice-type coset code, and a considerable shaping gain. Trellis precoding may be viewed as a generalization of trellis shaping to Gaussian ISI channels; or, alternatively, as a generalization of TH precoding with coded modulation that achieves shaping gain. With trellis precoding channel capacity can be approached essentially as closely on any strictly band-limited, high signal-to-noise ratio Gaussian channel as on the ideal channel, using the same coding techniques. For first- or second-order FIR and IIR channels, it is shown that shaping gains close to 1 dB can be obtained with a two-dimensional 4-state trellis code. Trellis precoding is quite practical whenever channel information is available at the transmitter.