mirror of
https://github.com/denisidoro/navi
synced 2024-11-21 19:13:07 +00:00
parent
c4e9c7a90a
commit
95fc254736
4 changed files with 18 additions and 3 deletions
|
@ -8,5 +8,6 @@ export SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|||
cd "${SCRIPT_DIR}"
|
||||
find . -iname '*.sh' | xargs -I% dot code beautify %
|
||||
find scripts/* | xargs -I% dot code beautify %
|
||||
find shell/* | xargs -I% dot code beautify %
|
||||
dot code beautify "${SCRIPT_DIR}/test/run"
|
||||
dot code beautify "${SCRIPT_DIR}/navi"
|
||||
|
|
9
shell/widget.zsh
Normal file
9
shell/widget.zsh
Normal file
|
@ -0,0 +1,9 @@
|
|||
_call_navi() {
|
||||
# zle kill-whole-line
|
||||
zle -U "$(NAVI_FZF_ALL_INPUTS=true navi --print "$(echo "$CUTBUFFER" | xargs)" <> /dev/tty)"
|
||||
zle accept-line
|
||||
}
|
||||
|
||||
zle -N _call_navi
|
||||
|
||||
bindkey '\eg' _call_navi
|
|
@ -60,10 +60,15 @@ arg::pick() {
|
|||
done
|
||||
|
||||
if [ -n "$fn" ]; then
|
||||
eval "$fn" | ui::pick --prompt "$arg: " --header-lines "${headers:-0}" | str::column "${column:-}"
|
||||
local suggestions="$(eval "$fn" 2>/dev/null)"
|
||||
if [ -n "$suggestions" ]; then
|
||||
echo "$suggestions" | ui::pick --prompt "$arg: " --header-lines "${headers:-0}" | str::column "${column:-}"
|
||||
fi
|
||||
elif ${NAVI_FZF_ALL_INPUTS:-false}; then
|
||||
echo "" | ui::pick --prompt "$arg: " --print-query --height 1
|
||||
else
|
||||
printf "\033[0;36m${arg}:\033[0;0m " > /dev/tty
|
||||
read value
|
||||
read -r value
|
||||
ui::clear_previous_line > /dev/tty
|
||||
printf "$value"
|
||||
fi
|
||||
|
|
|
@ -30,7 +30,7 @@ handler::main() {
|
|||
|
||||
value="$(arg::pick "$arg" "$cheat" || echo "")"
|
||||
if [ -z "$value" ]; then
|
||||
echo "$cmd"
|
||||
echoerr "Unable to fetch suggestions for '$arg'!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue