Use fzf by default for build-dir selector
This commit is contained in:
parent
f50db402af
commit
0efb635f02
@ -85,6 +85,18 @@ EOF
|
|||||||
if [[ ${#local_build_dirs} -eq 0 ]]; then
|
if [[ ${#local_build_dirs} -eq 0 ]]; then
|
||||||
error "no build directories found"; return 1
|
error "no build directories found"; return 1
|
||||||
elif [[ ${#local_build_dirs} -gt 1 ]]; then
|
elif [[ ${#local_build_dirs} -gt 1 ]]; then
|
||||||
|
if command -v fzf &> /dev/null; then
|
||||||
|
# Use fzf to select a build directory
|
||||||
|
local_build_dir=$(
|
||||||
|
printf '%s\n' "${local_build_dir[@]}" $local_build_dirs |
|
||||||
|
fzf --layout=reverse --info=hidden --border=rounded \
|
||||||
|
--height=$(( ${#local_build_dirs} + 5 ))
|
||||||
|
)
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Fallback to zcurses selector when fzf is not available
|
||||||
zmodload zsh/curses && {
|
zmodload zsh/curses && {
|
||||||
# Get the size of the terminal
|
# Get the size of the terminal
|
||||||
local size=`stty size`
|
local size=`stty size`
|
||||||
@ -138,14 +150,16 @@ EOF
|
|||||||
zcurses delwin build-dir
|
zcurses delwin build-dir
|
||||||
zcurses end
|
zcurses end
|
||||||
}
|
}
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# On success setup the build directory for use
|
# On success setup the build directory for use
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
# Set the build directory from selection if empty
|
# Set the build directory from selection if empty
|
||||||
[[ -z $local_build_dir ]] && \
|
[[ -z $local_build_dir ]] && \
|
||||||
local_build_dir=${local_build_dirs[$index+1]}
|
local_build_dir=${local_build_dirs[$index+1]}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# If `build.ninja` exists in alias `ninja`, return.
|
# If `build.ninja` exists in alias `ninja`, return.
|
||||||
local build
|
local build
|
||||||
@ -176,7 +190,6 @@ EOF
|
|||||||
if [[ -n $do_build ]]; then
|
if [[ -n $do_build ]]; then
|
||||||
eval build
|
eval build
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Build then run a target residing in `~build/bin`.
|
# Build then run a target residing in `~build/bin`.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user