]> git.nbdom.net Git - nb.git/commitdiff
etc/profile.d/functions hl()
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 19 Jan 2026 09:16:58 +0000 (10:16 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 19 Jan 2026 09:16:58 +0000 (10:16 +0100)
etc/profile.d/functions

index 6a7c6fbeaaa4ddb3e626056a0985a39bd4f03130..9c23e5c53305dc6024518980fc5bbdbf29612dcc 100755 (executable)
@@ -332,7 +332,13 @@ json2perl() {
 
 hl(){ 
        #cat | grep --color=always -E "(^|($@))"
-       perl -MTerm::ANSIColor -pe 'BEGIN{$|=1;}; $e=qq@'"$@"'@;$e=~s,/,\\/,g; s/($e)/color("red").$1.color("reset")/ge'
+       local color=red
+       if [ "$1" = "-color" ]; then
+               shift
+               color=$1
+               shift
+       fi
+       perl -MTerm::ANSIColor -pe 'BEGIN{$|=1;}; $e=qq@'"$@"'@;$e=~s,/,\\/,g; s/($e)/color("'$color'").$1.color("reset")/ge'
 }
 
 ls_tree() {