Daniel Sheffield 3 månader sedan
förälder
incheckning
00e0565268
1 ändrade filer med 14 tillägg och 1 borttagningar
  1. 14 1
      recall.sh

+ 14 - 1
recall.sh

@@ -92,6 +92,19 @@ shift $((OPTIND-1))
 
 validate "$@"
 
+fzf_rw0_inplace_preview () {
+	# NOTE: to preview and select captured command directories
+	fzf \
+		--read0 --print0 \
+		-m --no-sort \
+		"$@" \
+		-d / \
+		--nth 1,2,3 \
+		--preview-window="~2" \
+		--preview='cat {}/info; head -n "$LINES" {}/dat' \
+	&& :
+}
+
 if "$LIST_MODE"
 then
 	fzf_query=()
@@ -113,7 +126,7 @@ then
 			-print0 \
 		| sort -zV \
 		| head -zn "${NUM:--0}" \
-		| fzf --read0 --print0 -m --no-sort "${fzf_query[@]}" -d / --nth 1,2,3 --preview='cat {}/info; head {}/dat' \
+		| fzf_rw0_inplace_preview \
 		| awk -v RS='\0' -v FS='/' -v OFS='/' -v ORS='\0' '{for (i=2; i<=NF; i++) printf "%s%s", $(i), (i<NF ? OFS : ORS)}' \
 		| awk -v prefix="$LOG_ROOT/" -v RS='\0' -v ORS='\n' '{print prefix $0}' \
 		&& : "TODO: allow configuring null terminated output"