1/16/2017

Color-highlight given regex in MacOS 10.10 (Yosemite) or later

Using grep to filter commands' output is as easy as this:

mvn dependency:tree | grep selenium
Downloading: http://nexus.m44studio.com:8081/repository/maven-public/org/hpsl/common-selenium-integration-test/1.1.129-SNAPSHOT/maven-metadata.xml
Downloaded: http://nexus.m44studio.com:8081/repository/maven-public/org/hpsl/common-selenium-integration-test/1.1.129-SNAPSHOT/maven-metadata.xml (2 KB at 133.6 KB/sec)
[INFO] +- org.hpsl:common-selenium-integration-test:jar:1.1.129-SNAPSHOT:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-firefox-driver:jar:3.0.1:compile
[INFO] |  |  \- org.seleniumhq.selenium:selenium-remote-driver:jar:3.0.1:compile
[INFO] |  |     +- org.seleniumhq.selenium:selenium-api:jar:3.0.1:compile
[INFO] |  \- org.seleniumhq.selenium:selenium-java:jar:3.0.1:compile
[INFO] |     +- org.seleniumhq.selenium:selenium-chrome-driver:jar:3.0.1:compile
[INFO] |     +- org.seleniumhq.selenium:selenium-edge-driver:jar:3.0.1:compile
[INFO] |     +- org.seleniumhq.selenium:selenium-ie-driver:jar:3.0.1:compile
[INFO] |     +- org.seleniumhq.selenium:selenium-opera-driver:jar:3.0.1:compile
[INFO] |     +- org.seleniumhq.selenium:selenium-safari-driver:jar:3.0.1:compile
[INFO] |     +- org.seleniumhq.selenium:selenium-support:jar:3.0.1:compile

Well as the example above is using maven to show dependencies for a given project, filtered only for selenium - what if you want to see all the dependencies, having selenium highlighted with color? Here we go:

mvn dependency:tree | grep --color -E 'selenium|$'
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ integration-tests ---
[INFO] com.doma.blueprint.cdi:integration-tests:jar:1.0.73-SNAPSHOT
[INFO] +- com.doma.blueprint.cdi:model:jar:1.0.73-SNAPSHOT:compile
[INFO] |  \- com.doma.annotations.blueprint.cdi:annotations:jar:1.0.73-SNAPSHOT:compile
[INFO] +- org.eclipse.persistence:org.eclipse.persistence.moxy:jar:2.6.0:compile
[INFO] |  +- org.eclipse.persistence:org.eclipse.persistence.core:jar:2.6.0:compile
[INFO] |  |  \- org.eclipse.persistence:org.eclipse.persistence.asm:jar:2.6.0:compile
[INFO] |  +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] |  \- org.glassfish:javax.json:jar:1.0.4:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.5.2:compile
[INFO] |  +- org.apache.httpcomponents:httpcore:jar:4.4.4:compile
[INFO] |  +- commons-logging:commons-logging:jar:1.2:compile
[INFO] |  \- commons-codec:commons-codec:jar:1.9:compile
[INFO] +- commons-httpclient:commons-httpclient:jar:3.1:compile
[INFO] +- junit:junit:jar:4.12:compile
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.7:compile
[INFO] +- org.slf4j:log4j-over-slf4j:jar:1.7.5:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.1.3:compile
[INFO] |  \- ch.qos.logback:logback-core:jar:1.1.3:compile
[INFO] +- com.consol.citrus:citrus-core:jar:2.5.1:test
[INFO] |  +- com.consol.citrus.model:citrus-model-core:jar:2.5.1:test
[INFO] |  |  +- javax.xml.bind:jaxb-api:jar:2.2.11:test
[INFO] |  |  +- com.sun.xml.bind:jaxb-core:jar:2.2.11:test
[INFO] |  |  \- com.sun.xml.bind:jaxb-impl:jar:2.2.11:test
[INFO] |  +- commons-cli:commons-cli:jar:1.3.1:test
[INFO] |  +- commons-lang:commons-lang:jar:2.6:test
[INFO] |  +- xalan:xalan:jar:2.7.2:test
[INFO] |  |  \- xalan:serializer:jar:2.7.2:test
[INFO] |  +- xerces:xercesImpl:jar:2.11.0:test
[INFO] |  |  \- xml-apis:xml-apis:jar:1.4.01:test
[INFO] |  +- wsdl4j:wsdl4j:jar:1.6.3:test
[INFO] |  +- net.sf.jtidy:jtidy:jar:r938:test
[INFO] |  +- org.codehaus.groovy:groovy:jar:2.4.5:test
[INFO] |  +- org.codehaus.groovy:groovy-xml:jar:2.4.5:test
[INFO] |  +- org.codehaus.groovy:groovy-json:jar:2.4.5:test
[INFO] |  +- org.codehaus.groovy:groovy-jsr223:jar:2.4.5:test
[INFO] |  +- commons-logging:commons-logging-api:jar:1.1:test
[INFO] |  +- com.fasterxml.jackson.core:jackson-core:jar:2.6.3:test
[INFO] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.6.3:test
[INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.6.3:test
[INFO] |  +- net.minidev:json-smart:jar:2.2.1:test
[INFO] |  |  \- net.minidev:accessors-smart:jar:1.1:test
[INFO] |  |     \- org.ow2.asm:asm:jar:5.0.3:test
[INFO] |  +- com.jayway.jsonpath:json-path:jar:2.0.0:test
[INFO] |  +- org.springframework:spring-core:jar:4.2.3.RELEASE:test
[INFO] |  +- org.springframework:spring-context:jar:4.2.3.RELEASE:test
[INFO] |  |  +- org.springframework:spring-aop:jar:4.2.3.RELEASE:test
[INFO] |  |  |  \- aopalliance:aopalliance:jar:1.0:test
[INFO] |  |  +- org.springframework:spring-beans:jar:4.2.3.RELEASE:test
[INFO] |  |  \- org.springframework:spring-expression:jar:4.2.3.RELEASE:test
[INFO] |  +- org.springframework:spring-jdbc:jar:4.2.3.RELEASE:test
[INFO] |  |  \- org.springframework:spring-tx:jar:4.2.3.RELEASE:test
[INFO] |  +- org.springframework.integration:spring-integration-core:jar:4.2.2.RELEASE:test
[INFO] |  |  +- org.springframework.retry:spring-retry:jar:1.1.2.RELEASE:test
[INFO] |  |  \- org.springframework:spring-messaging:jar:4.2.3.RELEASE:test
[INFO] |  +- org.springframework.ws:spring-xml:jar:2.2.3.RELEASE:test
[INFO] |  +- org.springframework:spring-oxm:jar:4.2.3.RELEASE:test
[INFO] |  \- org.springframework:spring-test:jar:4.2.3.RELEASE:test
[INFO] +- org.hpsl:common-selenium-integration-test:jar:1.1.129-SNAPSHOT:compile
[INFO] |  +- com.github.tntim96:JSCover:jar:1.0.24:compile
[INFO] |  |  \- org.mozilla:rhino:jar:1.7.7.1:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-firefox-driver:jar:3.0.1:compile
[INFO] |  |  \- org.seleniumhq.selenium:selenium-remote-driver:jar:3.0.1:compile
[INFO] |  |     +- org.seleniumhq.selenium:selenium-api:jar:3.0.1:compile
[INFO] |  |     +- cglib:cglib-nodep:jar:3.2.4:compile
[INFO] |  |     +- org.apache.commons:commons-exec:jar:1.3:compile
[INFO] |  |     +- com.google.code.gson:gson:jar:2.3.1:compile
[INFO] |  |     +- com.google.guava:guava:jar:19.0:compile
[INFO] |  |     +- org.apache.httpcomponents:httpmime:jar:4.5.2:compile
[INFO] |  |     \- net.java.dev.jna:jna-platform:jar:4.1.0:compile
[INFO] |  |        \- net.java.dev.jna:jna:jar:4.1.0:compile
[INFO] |  +- com.codeborne:phantomjsdriver:jar:1.3.0:compile
[INFO] |  \- org.seleniumhq.selenium:selenium-java:jar:3.0.1:compile
[INFO] |     +- org.seleniumhq.selenium:selenium-chrome-driver:jar:3.0.1:compile
[INFO] |     +- org.seleniumhq.selenium:selenium-edge-driver:jar:3.0.1:compile
[INFO] |     +- org.seleniumhq.selenium:selenium-ie-driver:jar:3.0.1:compile
[INFO] |     +- org.seleniumhq.selenium:selenium-opera-driver:jar:3.0.1:compile
[INFO] |     +- org.seleniumhq.selenium:selenium-safari-driver:jar:3.0.1:compile
[INFO] |     |  \- io.netty:netty:jar:3.5.7.Final:compile
[INFO] |     +- org.seleniumhq.selenium:selenium-support:jar:3.0.1:compile
[INFO] |     +- net.sourceforge.htmlunit:htmlunit:jar:2.23:compile
[INFO] |     |  +- org.apache.commons:commons-lang3:jar:3.4:compile
[INFO] |     |  +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.23:compile
[INFO] |     |  +- net.sourceforge.htmlunit:neko-htmlunit:jar:2.23:compile
[INFO] |     |  +- net.sourceforge.cssparser:cssparser:jar:0.9.20:compile
[INFO] |     |  |  \- org.w3c.css:sac:jar:1.3:compile
[INFO] |     |  \- commons-io:commons-io:jar:2.5:compile
[INFO] |     \- org.eclipse.jetty.websocket:websocket-client:jar:9.2.15.v20160210:compile
[INFO] |        +- org.eclipse.jetty:jetty-util:jar:9.2.15.v20160210:compile
[INFO] |        +- org.eclipse.jetty:jetty-io:jar:9.2.15.v20160210:compile
[INFO] |        \- org.eclipse.jetty.websocket:websocket-common:jar:9.2.15.v20160210:compile
[INFO] |           \- org.eclipse.jetty.websocket:websocket-api:jar:9.2.15.v20160210:compile
[INFO] +- org.ops4j.pax.cdi:pax-cdi-api:jar:0.5.0:compile
[INFO] |  \- org.osgi:org.osgi.compendium:jar:4.3.1:compile
[INFO] +- javax.inject:javax.inject:jar:1:compile
[INFO] +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.7:compile
[INFO] +- org.osgi:org.osgi.core:jar:4.3.1:compile
[INFO] \- log4j:log4j:jar:1.2.17:test
Tested with Mac OSX 10.10 Yosemite. Enjoy!