0

I have following bash script to find git repositories.

echo "$(fd -I -i -H -E '.local' -E '.cargo' -E '.password-store' -t d ^.git$ ~ -x 'echo' '{//}' | sk)"

fd pipes search results to sk (fzf rust alternative) as they are being found but selecting one item waits until fd to finish. So there is like a 2 second delay from me selecting the directory using sk to it actually being echoed. I can see the same behavior with fzf too.

Is there a way to avoid the delay?

s1n7ax
  • 387
  • 3
  • 12

1 Answers1

0

After few hours I came up with this. There are probably better solutions but this works too.

#!/bin/env bash

quick_exit ()
{
  read VAR
  if [ ! -z "${VAR}" ]; then
    echo $VAR
    PID=$$
    kill $PID 2&> /dev/null
  fi
}

fd -I -i -H \
  -E '.local' \
  -E '.cargo' \
  -E '.password-store' \
  -t d ^.git$ ~ \
  -x 'echo' '{//}' | sk | quick_exit
s1n7ax
  • 387
  • 3
  • 12