m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-18 16:45:38 -05:00

Updated Examples (markdown)

Guy Stan
2020-07-23 18:49:37 +01:00
parent 7fea60675a
commit 68df5039da

@@ -295,8 +295,6 @@ fif() {
}
```
Suggested by [@gbstan](https://github.com/gbstan)
```sh
# alternative using ripgrep-all (rga) combined with fzf-tmux preview
# implementation below makes use of "open" on macOS, which can be replaced by other commands if needed.
@@ -305,10 +303,26 @@ Suggested by [@gbstan](https://github.com/gbstan)
fif() {
if [ ! "$#" -gt 0 ]; then echo "Need a string to search for!"; return 1; fi
local file
file="$(rga --max-count=1 --ignore-case --files-with-matches --no-messages "$@" | fzf-tmux +m --preview="rga --ignore-case --pretty --context 10 '"$@"' {}")" && open "$file"
file="$(rga --max-count=1 --ignore-case --files-with-matches --no-messages "$*" | fzf-tmux +m --preview="rga --ignore-case --pretty --context 10 '"$*"' {}")" && echo "opening $file" && open "$file" || return 1;
}
```
Suggested by [@gbstan](https://github.com/gbstan)
```sh
# alternative using ripgrep-all (rga) combined with sk preview
# This requires sk (skim) installed: https://github.com/lotabout/skim
# This will open the selected entry with SublimeText at the precise line and column where the entry is
# skrga: rga + subl - usage: skrga or skrga match_in_content_of_files or skgra regex_match_in_content_of_files
# If you provide arguments to skrga you can then use ctrl+q on the list of matches to filter with patterns appearing in each of the lines returned by sk
skrga() {
local file
file="$(sk-tmux --bind "ctrl-p:toggle-preview" --ansi -i --cmd-query "$*" -c 'rga --ignore-case --color=always --line-number --column {}' --preview 'bat --color=always --style=header,numbers --highlight-line "$(echo {1}|cut -d: -f2)" --line-range "$(($(echo {1}|cut -d: -f2))):$(($(echo {1}|cut -d: -f2)+50))" "$(echo {1}|cut -d: -f1)"')"; [[ $? -eq 0 ]] && echo "opening $file" && subl "$(echo "$file"|cut -d: -f1):$(echo "$file"|cut -d: -f2):$(echo "$file"|cut -d: -f3)" || return 1;
}
```
Suggested by [@gbstan](https://github.com/gbstan)
```sh
#!/bin/bash