diff options
author | Thomas Haller <thaller@redhat.com> | 2018-02-12 10:53:02 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-02-12 13:06:49 +0100 |
commit | 3d4181294508d4493355afd06d4f56ea47bba9d9 (patch) | |
tree | cfda332becba85b193cfc4c131656067771b4f7a | |
parent | aae263fbf2e20b3b9f36fd9b2dc807b2f39ca34b (diff) | |
download | NetworkManager-3d4181294508d4493355afd06d4f56ea47bba9d9.tar.gz |
contrib: add -h option to NM-log
Pass "-h" to highlight individual words.
"-h" stands for "highlight".
$ NM-log -h wlan0 j
-rwxr-xr-x | contrib/scripts/NM-log | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/contrib/scripts/NM-log b/contrib/scripts/NM-log index 8ba2a36ed0..49e187bae6 100755 --- a/contrib/scripts/NM-log +++ b/contrib/scripts/NM-log @@ -38,15 +38,32 @@ NM-colorize() { GREP_COLOR='01;31' grep -a --color=always '^\|^\(.* \)\?<\(warn> \|error>\) \[[0-9.]*\]' | \ GREP_COLOR='01;33' grep -a --color=always '^\|^\(.* \)\?<info> \[[0-9.]*\]\( .*\<is starting\>.*$\)\?' | \ GREP_COLOR='01;37' grep -a --color=always '^\|\<platform: signal: .*$' | \ - GREP_COLOR='01;34' grep -a --color=always '^\|\<platform\(-linux\)\?: link: \(add\|adding\|change\|setting\|deleting\) \|\<platform: address: \(deleting\|adding or updating\) IPv. address:\? \|\<platform: \(route\|ip4-route\|ip6-route\|qdisc\|tfilter\): \([a-z]\+\|adding or updating\|new\[0x[0-9A-Za-z]*\]\) \|\<platform-linux: sysctl: setting ' | \ + GREP_COLOR='01;34' grep -a --color=always '^\|\<platform\(-linux\)\?: link: \(add\|adding\|change\|setting\|deleting\) \|\<platform: address: \(deleting\|adding or updating\) IPv. address:\? \|\<platform: \(route\|ip4-route\|ip6-route\|qdisc\|tfilter\): \([a-z]\+\|adding or updating\|new\[0x[0-9A-Za-z]*\]\) \|\<platform-linux: sysctl: setting ' | \ GREP_COLOR='01;35' grep -a --color=always '^\|\<audit: .*$' | \ - GREP_COLOR='01;32' grep -a --color=always '^\|\<device (.*): state change: ' + GREP_COLOR='01;32' grep -a --color=always '^\|\<device (.*): state change: ' | + if [[ "$NM_LOG_GREP" != "" ]]; then + GREP_COLOR='01;36' grep -a --color=always "^\\|$NM_LOG_GREP" + else + /usr/bin/cat - + fi else /usr/bin/cat - fi } NM-log() { + local NM_LOG_GREP= + + while [[ $# -gt 0 ]]; do + if [[ "$1" == "-h" ]]; then + shift + NM_LOG_GREP="${NM_LOG_GREP+$NM_LOG_GREP\\|}\\<$1\\>" + shift + else + break + fi + done + ( if [ "$1" == "j" ]; then shift @@ -59,7 +76,7 @@ NM-log() { /usr/bin/less "$a" "$@" fi ) | \ - NM-colorize | \ + NM_LOG_GREP="$NM_LOG_GREP" NM-colorize | \ LESS=FRSXM less -R } |