mirror of
https://github.com/denisidoro/navi
synced 2024-11-25 13:00:20 +00:00
parent
e3f6a0418d
commit
1bd1730e8d
3 changed files with 15 additions and 2 deletions
|
@ -79,7 +79,7 @@ arg::pick() {
|
||||||
if [ -n "$fn" ]; then
|
if [ -n "$fn" ]; then
|
||||||
local suggestions="$(eval "$fn" 2>/dev/null)"
|
local suggestions="$(eval "$fn" 2>/dev/null)"
|
||||||
if [ -n "$suggestions" ]; then
|
if [ -n "$suggestions" ]; then
|
||||||
echo "$suggestions" | ui::fzf --prompt "$arg: " --header-lines "${headers:-0}" | str::column "${column:-}"
|
echo "$suggestions" | ui::fzf --prompt "$arg: " --header-lines "${headers:-0}" | str::column "${column:-}" "${separator:-}"
|
||||||
fi
|
fi
|
||||||
elif ${NAVI_USE_FZF_ALL_INPUTS:-false}; then
|
elif ${NAVI_USE_FZF_ALL_INPUTS:-false}; then
|
||||||
echo "" | ui::fzf --prompt "$arg: " --print-query --no-select-1 --height 1
|
echo "" | ui::fzf --prompt "$arg: " --print-query --no-select-1 --height 1
|
||||||
|
|
12
src/misc.sh
12
src/misc.sh
|
@ -34,4 +34,16 @@ tap() {
|
||||||
die() {
|
die() {
|
||||||
echoerr "$@"
|
echoerr "$@"
|
||||||
exit 42
|
exit 42
|
||||||
|
}
|
||||||
|
|
||||||
|
or() {
|
||||||
|
local -r x="$(cat)"
|
||||||
|
local -r y="${1:-}"
|
||||||
|
|
||||||
|
if [ -n "$x" ]; then
|
||||||
|
echo "$x"
|
||||||
|
elif [ $# -gt 0 ]; then
|
||||||
|
shift
|
||||||
|
echo "$y" | or "$@"
|
||||||
|
fi
|
||||||
}
|
}
|
|
@ -17,9 +17,10 @@ str::sub() {
|
||||||
|
|
||||||
str::column() {
|
str::column() {
|
||||||
local -r n="${1:-}"
|
local -r n="${1:-}"
|
||||||
|
local -r separator="$(echo "${2:-}" | or " +")"
|
||||||
|
|
||||||
if [ -n "$n" ]; then
|
if [ -n "$n" ]; then
|
||||||
awk "{print \$$n}"
|
awk -F "${separator:- }" "{print \$$n}"
|
||||||
else
|
else
|
||||||
cat
|
cat
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue