-
Notifications
You must be signed in to change notification settings - Fork 242
Tips and tricks
LoricAndre edited this page Jan 15, 2026
·
3 revisions
Use fzf-tab with skim
Install fzf-tab, then add this to your zshrc:
zstyle ':fzf-tab:*' use-fzf-default-opts yes
zstyle ':fzf-tab:*' fzf-command sk
zstyle ':fzf-tab:*' fzf-flags --bind=enter:'accept(enter)' --bind='/':'accept(/)' --bind='alt-enter':'accept(alt-enter)'__grep() {
local glob="$1"
local cmd="sk --exact --ansi -i -c \"rg --glob $glob -S --color=always --line-number '{}'\" -m --color=16 | cut -f1,2 -d':' | awk '!x[\$0]++' | tac"
setopt localoptions pipefail 2> /dev/null
eval "$cmd" | while read item; do
echo -n "${(q)item} "
done
local ret=$?
echo
return $ret
}
skim-grep-widget() {
LBUFFER="${LBUFFER}$(__grep $LBUFFER)"
local ret=$?
zle reset-prompt
return $ret
}
zle -N skim-grep-widget
# make sure to turn off flow control first (ctrl-s, ctrl-q) using:
# stty stop undef
# stty start undef
bindkey '^s' skim-grep-widgetAllows to search in PDFs, E-Books, Office documents, zip, tar.gz, etc. (see https://github.com/phiresky/ripgrep-all) using ripgrep-all (rga) combined with sk preview This requires ripgrep-all (rga) installed: https://github.com/phiresky/ripgrep-all This also uses bat for the preview: https://github.com/sharkdp/bat 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 As an output, this will open the selected entry with SublimeText at the precise line and column where the entry is
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;
}