dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

irg (506B)


      1 #!/usr/bin/env bash
      2 # Unfortunately, the single-char read syntax is not POSIX compatible,
      3 # and backspace is not supported
      4 
      5 nl='
      6 '
      7 query=""
      8 echo
      9 while :; do
     10 	printf "%s" "> $query"
     11 	read -sN1 -r q
     12 	case "$q" in
     13 		#("$backspace")  # TODO
     14 		#	query="${query%?}"; q="";;
     15 		("$nl")
     16 			f="$(echo "$out" | sed -n '$s/:.*//p')"; clear; echo "$f"; exit 0;;
     17 	esac
     18 	query="${query}${q}"
     19 	out="$(rg --column --line-number --no-heading --color=always \
     20 		 --smart-case -f <(echo "$query"))"
     21 	printf "%s\n" "$out"
     22 done