Truc et astuces: Apt search en couleurs dans less

felix via gull <gull-04vmY7CpswVinyhjFObuvR+/[email protected]>
Newsgroups gmane.org.user-groups.gull.general
Message-ID <[email protected]>
J'ai enfin trouvé une combine pour lire la sortie de apt search
dans less:

Au lieu de 

  apt search openvpn | less +/openvpn

qui affiche:

  WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

et supprime la colorisation

Ce que j'ai trouvé de plus simple:

  script -f /dev/null -c 'apt search openvpn' |
      tac | tac | { read _ && sed \$d |less -r +/openvpn ;}


Donc ma fonction:
  aptSearch () {
      script -f /dev/null -c "apt search '$1'" | 
	  tac | tac | { read _ && sed \$d | less -r ${2:++/}${2} ;}
  }

Le premier argument est passé à `apt search`, tandis que le second
est facultatif, passé a `less` avec ``+/'' si fourni.

-- 
 Félix Hauri  -  <[email protected]>  -  http://www.f-hauri.ch
_______________________________________________
gull mailing list
[email protected]
https://forum.linux-gull.ch/mailman/listinfo/gull
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.