Ignore long lines in silversearcher
I can think of three options:
Just print the result of your search instead of the whole line, using the -o option:
ag --color -o
Use less instead of cut which nicely chops long lines at the screen size's width using the -S option (chop long lines) and the -R option (to deal with the color escape sequences):
ag --color <pattern> | less -R -S
Use something like sed or awk instead of cut:
ag --color <pattern> |sed -E "s/(.{$COLUMNS}).*$/\1/"
Which will cut the returned line at the limit of your screen size. Of course, if you're determined to chop at 120 columns, you can: ag --color <pattern> |sed -E "s/(.{120}).*$/\1/"
This last option doesn't prevent the possibility of chopping in the middle of a color escape sequence; if you're really hellbent, you can modify the sed search pattern to ignore color escape sequences -- already answered on SO. That said, I don't see the purpose of doing this given the easiness and correctness of option 1 above.
Very strangely, the documented --print-long-lines
actually does nothing at all, yet there is a working switch for this: -W NUM / --width NUM
which is not documented at all. See https://github.com/ggreer/the_silver_searcher/pull/720