From 29a841cc9f1341be386f7a8228ae73953406ef6b Mon Sep 17 00:00:00 2001 From: Mathieu Ablasou Date: Tue, 24 Nov 2020 18:01:31 +0100 Subject: Add dmenu-grep, rofi-grep and wofi-grep commands --- rc/connect/modules/dmenu/commands/:dmenu-grep | 18 ++++++++++++++++++ rc/connect/modules/dmenu/dmenu.kak | 6 ++++++ rc/connect/modules/rofi/commands/:rofi-grep | 18 ++++++++++++++++++ rc/connect/modules/rofi/rofi.kak | 6 ++++++ rc/connect/modules/wofi/commands/:wofi-grep | 18 ++++++++++++++++++ rc/connect/modules/wofi/wofi.kak | 6 ++++++ 6 files changed, 72 insertions(+) create mode 100755 rc/connect/modules/dmenu/commands/:dmenu-grep create mode 100755 rc/connect/modules/rofi/commands/:rofi-grep create mode 100755 rc/connect/modules/wofi/commands/:wofi-grep diff --git a/rc/connect/modules/dmenu/commands/:dmenu-grep b/rc/connect/modules/dmenu/commands/:dmenu-grep new file mode 100755 index 0000000..cb02ed4 --- /dev/null +++ b/rc/connect/modules/dmenu/commands/:dmenu-grep @@ -0,0 +1,18 @@ +#!/bin/sh + +# dmenu +# https://tools.suckless.org/dmenu/ + +# Dependencies: +# – ripgrep (https://github.com/BurntSushi/ripgrep) + +rg --line-number --with-filename '.+' "$@" | +dmenu -l 20 -i -p 'Open files (search by content)' | + +while read line; do + # Output format: :: + file=${line%%:*} + line_number=${line#*:}; line_number=${line_number%%:*} + + :edit "$file" "+$line_number" +done diff --git a/rc/connect/modules/dmenu/dmenu.kak b/rc/connect/modules/dmenu/dmenu.kak index 17fdd8c..c5dd5e0 100644 --- a/rc/connect/modules/dmenu/dmenu.kak +++ b/rc/connect/modules/dmenu/dmenu.kak @@ -3,6 +3,7 @@ # Dependencies: # – fd (https://github.com/sharkdp/fd) +# – ripgrep (https://github.com/BurntSushi/ripgrep) provide-module connect-dmenu %{ # Modules @@ -22,6 +23,11 @@ provide-module connect-dmenu %{ $ :dmenu-buffers %arg{@} } + # Grep + define-command dmenu-grep -params .. -file-completion -docstring 'Open files (search by content) with dmenu' %{ + $ :dmenu-grep %arg{@} + } + # Aliases alias global dmenu dmenu-files } diff --git a/rc/connect/modules/rofi/commands/:rofi-grep b/rc/connect/modules/rofi/commands/:rofi-grep new file mode 100755 index 0000000..f0215a2 --- /dev/null +++ b/rc/connect/modules/rofi/commands/:rofi-grep @@ -0,0 +1,18 @@ +#!/bin/sh + +# Rofi +# https://github.com/davatorium/rofi + +# Dependencies: +# – ripgrep (https://github.com/BurntSushi/ripgrep) + +rg --line-number --with-filename '.+' "$@" | +rofi -dmenu -i -p 'Open files (search by content)' | + +while read line; do + # Output format: :: + file=${line%%:*} + line_number=${line#*:}; line_number=${line_number%%:*} + + :edit "$file" "+$line_number" +done diff --git a/rc/connect/modules/rofi/rofi.kak b/rc/connect/modules/rofi/rofi.kak index d53a5c8..d1af9c8 100644 --- a/rc/connect/modules/rofi/rofi.kak +++ b/rc/connect/modules/rofi/rofi.kak @@ -3,6 +3,7 @@ # Dependencies: # – fd (https://github.com/sharkdp/fd) +# – ripgrep (https://github.com/BurntSushi/ripgrep) provide-module connect-rofi %{ # Modules @@ -22,6 +23,11 @@ provide-module connect-rofi %{ $ :rofi-buffers %arg{@} } + # Grep + define-command rofi-grep -params .. -file-completion -docstring 'Open files (search by content) with Rofi' %{ + $ :rofi-grep %arg{@} + } + # Aliases alias global rofi rofi-files } diff --git a/rc/connect/modules/wofi/commands/:wofi-grep b/rc/connect/modules/wofi/commands/:wofi-grep new file mode 100755 index 0000000..a8c80fe --- /dev/null +++ b/rc/connect/modules/wofi/commands/:wofi-grep @@ -0,0 +1,18 @@ +#!/bin/sh + +# Wofi +# https://hg.sr.ht/~scoopta/wofi + +# Dependencies: +# – ripgrep (https://github.com/BurntSushi/ripgrep) + +rg --line-number --with-filename '.+' "$@" | +wofi --dmenu --prompt 'Open files (search by content)' | + +while read line; do + # Output format: :: + file=${line%%:*} + line_number=${line#*:}; line_number=${line_number%%:*} + + :edit "$file" "+$line_number" +done diff --git a/rc/connect/modules/wofi/wofi.kak b/rc/connect/modules/wofi/wofi.kak index f774b50..082419e 100644 --- a/rc/connect/modules/wofi/wofi.kak +++ b/rc/connect/modules/wofi/wofi.kak @@ -3,6 +3,7 @@ # Dependencies: # – fd (https://github.com/sharkdp/fd) +# – ripgrep (https://github.com/BurntSushi/ripgrep) provide-module connect-wofi %{ # Modules @@ -22,6 +23,11 @@ provide-module connect-wofi %{ $ :wofi-buffers %arg{@} } + # Grep + define-command wofi-grep -params .. -file-completion -docstring 'Open files (search by content) with Wofi' %{ + $ :wofi-grep %arg{@} + } + # Aliases alias global wofi wofi-files } -- cgit v1.2.3