Skip to content

Commit

Permalink
fzy: empty output if no valid selection
Browse files Browse the repository at this point in the history
necessary if not this issue leads to change in upstream `fzf`:
jhawthorn/fzy#105
  • Loading branch information
aude committed Feb 1, 2019
1 parent 3ca1fec commit b208661
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion .shrc.d/80aude.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function print_files() {
function choose() {
# check for actual binaries, aliases and stuff won't work without
if /usr/bin/which fzy >/dev/null 2>&1; then
fzy
fzy | exists | is_not_empty
elif /usr/bin/which fzf >/dev/null 2>&1; then
fzf --cycle
else
Expand All @@ -118,6 +118,24 @@ function choose() {
function select_file() {
print_files 2>/dev/null | choose
}
# helper functions
function exists() {
while read -r file; do
if [ -e "$file" ]; then
printf '%s\n' "$file"
fi
done
}
function is_not_empty() {
empty='true'
while read -r line; do
printf '%s\n' "$line"
empty='false'
done
if "$empty"; then
return 1
fi
}

# if BASH
if [[ -n $BASH_VERSION ]]; then
Expand Down

0 comments on commit b208661

Please sign in to comment.