• Stars
    star
    545
  • Rank 81,554 (Top 2 %)
  • Language
    Go
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Grep with colours

Blush

PkgGoDev GitHub go.mod Go version Build Status License: MIT Coverage Status Go Report Card

With Blush, you can highlight matches with any colours of your choice.

1

  1. Install
  2. Usage
  3. Arguments
  4. Colour Groups
  5. Colours
  6. Complex Grep
  7. Suggestions
  8. License

Install

You can grab a binary from releases page. If you prefer to install it manually you can get the code and install it with the following command:

$ go install github.com/arsham/blush@latest

Make sure you have go>=1.18 installed.

Usage

Blush can read from a file or a pipe:

$ cat FILENAME | blush -b "print in blue" -g "in green" -g "another green"
$ cat FILENAME | blush "some text"
$ blush -b "print in blue" -g "in green" -g "another green" FILENAME
$ blush "some text" FILENAME

Note

Although this program has a good performance, but performance is not the main concern. There are other tools you should use if you are searching in large files. Two examples:

Normal Mode

This method shows matches with the given input:

$ blush -b "first search" -g "second one" -g "and another one" files/paths

Any occurrence of first search will be in blue, second one and and another one are in green.

2

Dropping Unmatched

By default, unmatched lines are not dropped. But you can use the -d flag to drop them:

3

Arguments

Argument Shortcut Notes
N/A -i Case insensitive matching.
N/A -R Recursive matching.
--no-filename -h Suppress the prefixing of file names on output.
--drop -d Drop unmatched lines

File names or paths are matched from the end. Any argument that doesn't match any files or paths are considered as regular expression. If regular expressions are not followed by colouring arguments are coloured based on previously provided colour:

$ blush -b match1 match2 FILENAME

4

Notes

  • If no colour is provided, blush will choose blue.
  • If you only provide file/path, it will print them out without colouring.
  • If the matcher contains only alphabets and numbers, a non-regular expression is applied to search.

Colour Groups

You can provide a number for a colour argument to create a colour group:

$ blush -r1 match1 -r2 match2 -r1 match3 FILENAME

5

All matches will be shown as blue. But match1 and match3 will have a different background colour than match2. This means the numbers will create colour groups.

You also can provide a colour with a series of match requests:

$ blush -r match1 match3 -g match2 FILENAME

Colours

You can choose a pre-defined colour, or pass it your own colour with a hash:

Argument Shortcut
--red -r
--green -g
--blue -b
--white -w
--black -bl
--yellow -yl
--magenta -mg
--cyan -cy

You can also pass an RGB colour. It can be in short form (--#1b2, -#1b2), or long format (--#11bb22, -#11bb22).

6

Complex Grep

You must put your complex grep into quotations:

$ blush -b "^age: [0-9]+" FILENAME

7

Suggestions

This tool is made to make your experience in terminal a more pleasant. Please feel free to make any suggestions or request features by creating an issue.

License

Use of this source code is governed by the MIT License. License file can be found in the LICENSE file.

More Repositories

1

figurine

Print your name in style
Go
458
star
2

rainbow

Tasty rainbows for your terminal! (lolcat clone)
Go
64
star
3

shark

Neovim setup, all in Lua
Lua
30
star
4

arshamiser.nvim

Neovim status-bar based on feline, a colour scheme, and foldtext function
Lua
19
star
5

arshlib.nvim

Common library for using in neovim plugins
Lua
11
star
6

indent-tools.nvim

Neovim pluging for dealing with indentations
Lua
10
star
7

expipe

Ship your expvar metrics to elasticsearch
Go
10
star
8

listish.nvim

Neovim plugin for quickfix and local lists
Lua
9
star
9

fzfmania.nvim

Powerful FZF setup for Neovim in Lua
Lua
8
star
10

matchmaker.nvim

Neovim plugin for quickly highlighting matches
Lua
7
star
11

yanker.nvim

Neovim plugin for keeping a yank history
Lua
7
star
12

django-searchbar

A simple search bar and view handler to validate and get the results
Python
7
star
13

dotfiles

My dotfiles for zsh, tmux, etc.
Shell
6
star
14

archer.nvim

Neovim mappings and text objects for archers
Lua
6
star
15

gitrelease

This program can set the release information based on all commits of a tag
Go
5
star
16

django-cachedpaginator

Paginator that caches pages automatically
Python
5
star
17

gistflow

A Qt application for managing your gists
Go
4
star
18

dbtools

Go db helpers library for using in production code and tests.
Go
3
star
19

sublime-text-3

My Sublime Text 3 settings
Go
2
star
20

awesomewm-config

Awesome Window Manager config
Lua
1
star
21

retry

Retry a function until is succeeds
Go
1
star
22

SelectBetween

A sublime text plugin for selecting an area surrounded by a character at cursor(s) position
Python
1
star
23

GoToChar

A sublime text plugin for going to next/previous character
Python
1
star