mirror of
https://github.com/atuinsh/atuin.git
synced 2025-06-20 18:07:57 +02:00
refactor(bash): factorize __atuin_accept_line
(#1476)
This commit is contained in:
parent
1350d3fd74
commit
c7db7838e3
@ -21,18 +21,9 @@ __atuin_set_ret_value() {
|
|||||||
return ${1:+"$1"}
|
return ${1:+"$1"}
|
||||||
}
|
}
|
||||||
|
|
||||||
__atuin_history() {
|
__atuin_accept_line() {
|
||||||
# shellcheck disable=SC2048,SC2086
|
local HISTORY=$1
|
||||||
HISTORY="$(ATUIN_SHELL_BASH=t ATUIN_LOG=error atuin search $* -i -- "${READLINE_LINE}" 3>&1 1>&2 2>&3)"
|
|
||||||
|
|
||||||
if [[ $HISTORY == __atuin_accept__:* ]]
|
|
||||||
then
|
|
||||||
HISTORY=${HISTORY#__atuin_accept__:}
|
|
||||||
|
|
||||||
if [[ -n "${BLE_ATTACHED-}" ]]; then
|
|
||||||
ble-edit/content/reset-and-check-dirty "$HISTORY"
|
|
||||||
ble/widget/accept-line
|
|
||||||
else
|
|
||||||
# Reprint the prompt, accounting for multiple lines
|
# Reprint the prompt, accounting for multiple lines
|
||||||
local __atuin_prompt_offset
|
local __atuin_prompt_offset
|
||||||
__atuin_prompt_offset=$(echo -n "${PS1@P}" | tr -cd '\n' | wc -c)
|
__atuin_prompt_offset=$(echo -n "${PS1@P}" | tr -cd '\n' | wc -c)
|
||||||
@ -89,6 +80,21 @@ __atuin_history() {
|
|||||||
__atuin_set_ret_value "${__bp_last_ret_value-}" "${__bp_last_argument_prev_command-}"
|
__atuin_set_ret_value "${__bp_last_ret_value-}" "${__bp_last_argument_prev_command-}"
|
||||||
echo "${PS1@P}"
|
echo "${PS1@P}"
|
||||||
tput cuu 1
|
tput cuu 1
|
||||||
|
}
|
||||||
|
|
||||||
|
__atuin_history() {
|
||||||
|
# shellcheck disable=SC2048,SC2086
|
||||||
|
HISTORY="$(ATUIN_SHELL_BASH=t ATUIN_LOG=error atuin search $* -i -- "${READLINE_LINE}" 3>&1 1>&2 2>&3)"
|
||||||
|
|
||||||
|
if [[ $HISTORY == __atuin_accept__:* ]]
|
||||||
|
then
|
||||||
|
HISTORY=${HISTORY#__atuin_accept__:}
|
||||||
|
|
||||||
|
if [[ -n "${BLE_ATTACHED-}" ]]; then
|
||||||
|
ble-edit/content/reset-and-check-dirty "$HISTORY"
|
||||||
|
ble/widget/accept-line
|
||||||
|
else
|
||||||
|
__atuin_accept_line "$HISTORY"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
READLINE_LINE=""
|
READLINE_LINE=""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user