-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
425ce80
commit a36c26f
Showing
4 changed files
with
46 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
_navi_call() { | ||
local result="$(navi "$@" </dev/tty)" | ||
if [ -z "${result}" ]; then | ||
result="$(navi --print </dev/tty)" | ||
fi | ||
printf "%s" "$result" | ||
local result="$(navi "$@" </dev/tty)" | ||
printf "%s" "$result" | ||
} | ||
|
||
_navi_widget() { | ||
local -r input="${READLINE_LINE}" | ||
local -r last_command="$(echo "${input}" | navi fn widget::last_command)" | ||
local -r input="${READLINE_LINE}" | ||
local -r last_command="$(echo "${input}" | navi fn widget::last_command)" | ||
|
||
if [ -z "${last_command}" ]; then | ||
local -r output="$(FZF_OVERRIDES="${FZF_OVERRIDES:-} --no-select-1" _navi_call --print)" | ||
else | ||
local -r find="$last_command" | ||
local -r replacement="$(_navi_call --print --query "${last_command}")" | ||
local -r output="${input//$find/$replacement}" | ||
fi | ||
if [ -z "${last_command}" ]; then | ||
local -r output="$(_navi_call --print)" | ||
else | ||
local -r find="$last_command" | ||
local -r replacement="$(_navi_call --print --query "$last_command")" | ||
local output="$input" | ||
if [ -n "$replacement" ]; then | ||
output="${input//$find/$replacement}" | ||
fi | ||
fi | ||
|
||
READLINE_LINE="$output" | ||
READLINE_POINT=${#READLINE_LINE} | ||
READLINE_LINE="$output" | ||
READLINE_POINT=${#READLINE_LINE} | ||
} | ||
|
||
_navi_widget_legacy() { | ||
_navi_call --print | ||
_navi_call --print | ||
} | ||
|
||
if [ ${BASH_VERSION:0:1} -lt 4 ]; then | ||
bind '"\C-g": " \C-b\C-k \C-u`_navi_widget_legacy`\e\C-e\C-a\C-y\C-h\C-e\e \C-y\ey\C-x\C-x\C-f"' | ||
if [ ${BASH_VERSION:0:1} -lt 4 ]; then | ||
bind '"\C-g": " \C-b\C-k \C-u`_navi_widget_legacy`\e\C-e\C-a\C-y\C-h\C-e\e \C-y\ey\C-x\C-x\C-f"' | ||
else | ||
bind -x '"\C-g": _navi_widget' | ||
bind -x '"\C-g": _navi_widget' | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters