mirror of
https://github.com/denisidoro/navi
synced 2024-11-21 19:13:07 +00:00
Autoselect on single option (#68)
Based on #https://github.com/denisidoro/navi/pull/53 by @nikush. Fixes #44.
This commit is contained in:
parent
516578479c
commit
ea0fb00371
2 changed files with 13 additions and 2 deletions
|
@ -13,6 +13,7 @@ opts::eval() {
|
|||
local interpolation=true
|
||||
local preview=true
|
||||
local path="${NAVI_PATH:-${NAVI_DIR:-${SCRIPT_DIR}/cheats}}"
|
||||
local autoselect=true
|
||||
|
||||
for arg in "$@"; do
|
||||
case $wait_for in
|
||||
|
@ -33,9 +34,10 @@ opts::eval() {
|
|||
search) entry_point="search"; wait_for="search" ;;
|
||||
preview) entry_point="preview"; wait_for="preview" ;;
|
||||
q|query) wait_for="query" ;;
|
||||
--no-autoselect) autoselect=false ;;
|
||||
esac
|
||||
done
|
||||
|
||||
OPTIONS="$(dict::new entry_point "$entry_point" print "$print" interpolation "$interpolation" preview "$preview" query "${query:-}")"
|
||||
OPTIONS="$(dict::new entry_point "$entry_point" print "$print" interpolation "$interpolation" preview "$preview" autoselect "$autoselect" query "${query:-}")"
|
||||
export NAVI_PATH="$path"
|
||||
}
|
||||
|
|
11
src/ui.sh
11
src/ui.sh
|
@ -1,7 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
ui::pick() {
|
||||
fzf --height '100%' --inline-info "$@"
|
||||
local -r autoselect="$(dict::get "$OPTIONS" autoselect)"
|
||||
|
||||
local args=()
|
||||
args+=("--height")
|
||||
args+=("100%")
|
||||
if ${autoselect:-false}; then
|
||||
args+=("--select-1")
|
||||
fi
|
||||
|
||||
fzf "${args[@]:-}" --inline-info "$@"
|
||||
}
|
||||
|
||||
# TODO: separation of concerns
|
||||
|
|
Loading…
Reference in a new issue