summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Ablasou <alexherbo2@gmail.com>2020-11-24 17:09:44 +0100
committerMathieu Ablasou <alexherbo2@gmail.com>2020-11-24 17:09:44 +0100
commit951862f88f14b20b2adf5097c563e23936330161 (patch)
treedc8a4a77c90d657eb59a1ee2439d5c9c556c18a8
parent5028e62e1b081d2d6341e087e7d2f70444d018d3 (diff)
Add fzf-grep and fzy-grep commands
-rwxr-xr-xrc/connect/modules/fzf/commands/:fzf-grep18
-rw-r--r--rc/connect/modules/fzf/fzf.kak6
-rwxr-xr-xrc/connect/modules/fzy/commands/:fzy-grep18
-rw-r--r--rc/connect/modules/fzy/fzy.kak6
4 files changed, 48 insertions, 0 deletions
diff --git a/rc/connect/modules/fzf/commands/:fzf-grep b/rc/connect/modules/fzf/commands/:fzf-grep
new file mode 100755
index 0000000..41b1f89
--- /dev/null
+++ b/rc/connect/modules/fzf/commands/:fzf-grep
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# fzf
+# https://github.com/junegunn/fzf
+
+# Dependencies:
+# – ripgrep (https://github.com/BurntSushi/ripgrep)
+
+rg --line-number --with-filename '.+' "$@" |
+fzf --prompt='(g)>' |
+
+while read line; do
+ # Output format: <file>:<line>:<text>
+ file=${line%%:*}
+ line_number=${line#*:}; line_number=${line_number%%:*}
+
+ :edit "$file" "+$line_number"
+done
diff --git a/rc/connect/modules/fzf/fzf.kak b/rc/connect/modules/fzf/fzf.kak
index 9837765..07ef3c3 100644
--- a/rc/connect/modules/fzf/fzf.kak
+++ b/rc/connect/modules/fzf/fzf.kak
@@ -4,6 +4,7 @@
# Dependencies:
# – fd (https://github.com/sharkdp/fd)
# – bat (https://github.com/sharkdp/bat)
+# – ripgrep (https://github.com/BurntSushi/ripgrep)
provide-module connect-fzf %{
# Modules
@@ -23,6 +24,11 @@ provide-module connect-fzf %{
+ :fzf-buffers %arg{@}
}
+ # Grep
+ define-command fzf-grep -params .. -file-completion -docstring 'Open files (search by content) with fzf' %{
+ + :fzf-grep %arg{@}
+ }
+
# Aliases
alias global fzf fzf-files
}
diff --git a/rc/connect/modules/fzy/commands/:fzy-grep b/rc/connect/modules/fzy/commands/:fzy-grep
new file mode 100755
index 0000000..788a774
--- /dev/null
+++ b/rc/connect/modules/fzy/commands/:fzy-grep
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# fzy
+# https://github.com/jhawthorn/fzy
+
+# Dependencies:
+# – ripgrep (https://github.com/BurntSushi/ripgrep)
+
+rg --line-number --with-filename '.+' "$@" |
+fzy --prompt='(g)>' |
+
+while read line; do
+ # Output format: <file>:<line>:<text>
+ file=${line%%:*}
+ line_number=${line#*:}; line_number=${line_number%%:*}
+
+ :edit "$file" "+$line_number"
+done
diff --git a/rc/connect/modules/fzy/fzy.kak b/rc/connect/modules/fzy/fzy.kak
index 9d04bf8..42708f3 100644
--- a/rc/connect/modules/fzy/fzy.kak
+++ b/rc/connect/modules/fzy/fzy.kak
@@ -3,6 +3,7 @@
# Dependencies:
# – fd (https://github.com/sharkdp/fd)
+# – ripgrep (https://github.com/BurntSushi/ripgrep)
provide-module connect-fzy %{
# Modules
@@ -22,6 +23,11 @@ provide-module connect-fzy %{
+ :fzy-buffers %arg{@}
}
+ # Grep
+ define-command fzy-grep -params .. -file-completion -docstring 'Open files (search by content) with fzy' %{
+ + :fzy-grep %arg{@}
+ }
+
# Aliases
alias global fzy fzy-files
}