mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-03 17:10:26 +01:00
contrib: add -h option to NM-log
Pass "-h" to highlight individual words. "-h" stands for "highlight". $ NM-log -h wlan0 j
This commit is contained in:
parent
aae263fbf2
commit
3d41812945
1 changed files with 20 additions and 3 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue