How to truncate long matching lines returned by grep or ack

前端 未结 8 1733
攒了一身酷
攒了一身酷 2020-12-13 05:38

I want to run ack or grep on HTML files that often have very long lines. I don\'t want to see very long lines that wrap repeatedly. But I do want to see just that portion of

8条回答
  •  庸人自扰
    2020-12-13 05:58

    Here's what I do:

    function grep () {
      tput rmam;
      command grep "$@";
      tput smam;
    }
    

    In my .bash_profile, I override grep so that it automatically runs tput rmam before and tput smam after, which disabled wrapping and then re-enables it.

提交回复
热议问题