Skip to content
/ qse Public

Useful recipes of various CLI util integrations

Notifications You must be signed in to change notification settings

QtRoS/qse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 

Repository files navigation

🔍 qse

Useful recipes of various fzf+rga+bat integrations

Summary

About

This will repo will help you to search for code faster than ever.

Recipes

Basic version of qse:

qse() {
	RG_PREFIX="rg --files-with-matches"
	local file
	file="$(
		FZF_DEFAULT_COMMAND="$RG_PREFIX '$1'" \
			fzf \
				--preview="[[ ! -z {} ]] && rg --pretty --context 5 {q} {}" \
				--disabled --query "$1" \
				--bind "change:reload:sleep 0.1; $RG_PREFIX {q}" \
				--bind "f3:execute(bat --paging=always --pager=less --color=always {} < /dev/tty > /dev/tty)" \
				--bind "f4:execute(code {})" \
				--preview-window="70%:wrap"
	)" &&
	echo "$file"
}

asciicast

Advanced

Advanced version with bat-preview (and awesome batgrep)

export BAT_THEME="Monokai Extended"
qsb() {
	RG_PREFIX="rg --files-with-matches"
	local file
	file="$(
		FZF_DEFAULT_COMMAND="$RG_PREFIX '$1'" \
			fzf \
			--preview="if [[ -n {} ]]; then if [[ -n {q} ]]; then ~/bin/bat-extras/src/batgrep.sh --color=always --terminal-width=\$FZF_PREVIEW_COLUMNS --context=3 {q} {}; else bat --color=always {}; fi; fi" \
			--disabled --query "$1" \
			--bind "change:reload:sleep 0.1; $RG_PREFIX {q}" \
			--bind "f3:execute(bat --paging=always --pager=\"less -j4 -R +/{q}\" --color=always {} < /dev/tty > /dev/tty)" \
			--bind "f4:execute(code {})" \
			--preview-window="70%:wrap"
	)" &&
	echo "$file"
}

asciicast

Installation

Install bat, fzf, ripgrep

Then simply add recipe to your ~/.shrc or ~/.zshrc and restart the shell

About

Useful recipes of various CLI util integrations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published