Created
April 15, 2020 16:19
-
-
Save Tantalus13A98B5F/e774dd9a88696bea91ee330fb58928b8 to your computer and use it in GitHub Desktop.
fzf-pipe: `fzf` wrapper for Git Bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
TEMPDIR=$(mktemp -d) | |
cat >$TEMPDIR/input.txt | |
FZFOPTS="$(echo "$FZF_DEFAULT_OPTS" | sed 's/--height\s*\S*\s*//')" | |
for arg; do | |
FZFARGS="$FZFARGS \"$arg\"" | |
done | |
cat >$TEMPDIR/script.sh <<EOF | |
cat $TEMPDIR/input.txt | FZF_DEFAULT_OPTS="$FZFOPTS" fzf $FZFARGS >$TEMPDIR/output.txt 2>$TEMPDIR/errors.txt | |
echo "\${PIPESTATUS[1]}" >$TEMPDIR/status.txt | |
EOF | |
MSYS_NO_PATHCONV=1 cmd /C "set \"TERM=\" & start /WAIT sh -c $TEMPDIR/script.sh" | |
STATUS="$(cat $TEMPDIR/status.txt)" | |
cat $TEMPDIR/output.txt | |
rm -rf $TEMPDIR | |
exit $STATUS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment