Skip to content

Instantly share code, notes, and snippets.

@johngrib
Created December 17, 2018 05:08
Show Gist options
  • Save johngrib/ff613b4092645b74dfe53de3089b08af to your computer and use it in GitHub Desktop.
Save johngrib/ff613b4092645b74dfe53de3089b08af to your computer and use it in GitHub Desktop.
print list to fzf
#! /usr/bin/env bash
function list() {
tempFile1=/tmp/`uuidgen`
tempFile2=/tmp/`uuidgen`
cat test > $tempFile1
_line=`{ grep -En "^\\s*$" $tempFile1 | cut -d: -f1; wc -l $tempFile1 | awk '{print $1}'; }`
_start=2
for ln in $_line; do
cat $tempFile1 | sed -n "${_start},${ln}p" \
| grep -Ev "^\\s*$|^\\s*If no build" | sed 's/^ *//' > $tempFile2;
title=`cat $tempFile2 | head -n 1 | awk '{print $1}' | sed 's/://'`;
cat $tempFile2 | awk -v title="$title" '{print "["title"]", $0}';
rm $tempFile2;
_start=$ln;
done
rm $tempFile1
};
list | fzf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment