Skip to content

Commit 5abdd10

Browse files
SanchayanMaityvrothberg
authored andcommitted
README: Include examples for fish shell
1 parent fc9035c commit 5abdd10

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,25 @@ vgrep() {
9090
| awk '{print $1}' | xargs -I{} -o vgrep --show {}
9191
}
9292
```
93+
94+
### For fish shell
95+
96+
The below version pipes the result of the initial query with `vgrep` to `fzf` to allow further selection among the results.
97+
98+
```fish
99+
function vgf --wraps=vgrep --description 'vgrep search with fzf'
100+
set -f INITIAL_QUERY $argv[1]
101+
vgrep --no-header $INITIAL_QUERY | fzf --ansi --bind "Ctrl-d:half-page-down,Ctrl-u:half-page-up" | awk '{print $1}' | xargs -I{} -o vgrep --show {}
102+
end
103+
```
104+
105+
To have a variant, which restarts the search with `vgrep` on entering a new query, use the below version.
106+
107+
```fish
108+
function vgF --wraps=vgrep --description 'vgrep search with fzf'
109+
set -f INITIAL_QUERY $argv[1]
110+
FZF_DEFAULT_COMMAND="vgrep --no-header $INITIAL_QUERY" fzf --bind "Ctrl-d:half-page-down,Ctrl-u:half-page-up,change:reload:vgrep --no-header {q} || true" --ansi --phony --tac --query $INITIAL_QUERY | awk '{print $1}' | xargs -I{} -o vgrep --show {}
111+
end
112+
```
113+
114+
For further details on use of `functions` with `fish` shell, see [here](https://fishshell.com/docs/current/language.html#syntax-function).

0 commit comments

Comments
 (0)