~miconoco/q

60a7dfcc7fc4ce0c41d5538ebf5c97c69fac9a3b — Christoph Polcin 1 year, 2 months ago 499eae8 master
add findq
4 files changed, 86 insertions(+), 5 deletions(-)

A Makefile
M README
A findq
A findquelle
A Makefile => Makefile +8 -0
@@ 0,0 1,8 @@

.PHONY: install
install:
	ln -sr findquelle findq ~/bin/

uninstall:
	rm -f ~/bin/findquelle ~/bin/findq


M README => README +34 -5
@@ 11,11 11,40 @@ prolog
	FCK BIN FMT


q to rescue
===========
q to jump
=========

	usage: q [filter|PATH]
	usage: q [query]|[PATH]
	
	jumps into **Quellverzeichnis**

	quelle = T@ path

	return quellen
```sh
function q()
{
	f=/tmp/.q.$$
	~/bin/findq "$1" "$2" | sed -n '1 s|^|cd |p' > "$f" && . "$f" && rm -f -- "$f"
}
```


findq to rescue
===============

	usage: findq [query]|[PATH]
	
	return **Quelle**


Dependency: <https://github.com/junegunn/fzf>


findquelle
==========

	usage: findquelle [PATH]
	
	Quelle = T@;path
	
	return **Quellen**


A findq => findq +28 -0
@@ 0,0 1,28 @@
#!/bin/sh

if [ -d "$1" ]; then
	_root="$1"
	_q="${2}"
else
	_q="${1}"
	_root="${2:-.}"
fi

findquelle "${_root}" \
| sed 's|^[^;]*;'"${_root}"'||' \
| fzf -1 \
	--multi \
	--ansi \
	--cycle \
	--no-sort \
	--info inline \
	--reverse \
	--keep-right \
	--bind "ctrl-f:execute-silent(git --git-dir='${_root}{}/.git' remote update)+refresh-preview" \
	--filepath-word \
	--preview-window right:60%:nowrap:noborder \
	--preview "git --git-dir='${_root}{}/.git' lla --color=always -30" \
	--marker '+' \
	--prompt "${_root}>" \
	-q "$_q" \
| sed "s|^|${_root}|"

A findquelle => findquelle +16 -0
@@ 0,0 1,16 @@
#!/bin/sh

find "${1:-./}" \
	-maxdepth ${DEPTH:-7} \
	-type d \
	-name '.git' \
	-prune 2>/dev/null \
| sed 's/\.git$//' \
| sort -u \
| awk \
'BEGIN { old = "^-----" }
$0 ~ old { next }
{ old = "^"$0; print $0".git/index" }' \
| xargs stat -c '%Y;%n' 2>/dev/null \
| sort -n -k1 -r \
| sed 's|/.git/index$||'