Add bash support to enter_accept
(#1316)
This commit is contained in:
parent
d202afeaf5
commit
08a01e037c
3 changed files with 18 additions and 5 deletions
|
@ -119,10 +119,15 @@ pub fn is_zsh() -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_fish() -> bool {
|
pub fn is_fish() -> bool {
|
||||||
// only set on zsh
|
// only set on fish
|
||||||
env::var("ATUIN_SHELL_FISH").is_ok()
|
env::var("ATUIN_SHELL_FISH").is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_bash() -> bool {
|
||||||
|
// only set on bash
|
||||||
|
env::var("ATUIN_SHELL_BASH").is_ok()
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use time::Month;
|
use time::Month;
|
||||||
|
|
|
@ -703,7 +703,7 @@ pub async fn history(
|
||||||
|
|
||||||
if index < results.len() {
|
if index < results.len() {
|
||||||
let mut command = results.swap_remove(index).command;
|
let mut command = results.swap_remove(index).command;
|
||||||
if accept && (utils::is_zsh() || utils::is_fish()) {
|
if accept && (utils::is_zsh() || utils::is_fish() || utils::is_bash()) {
|
||||||
command = String::from("__atuin_accept__:") + &command;
|
command = String::from("__atuin_accept__:") + &command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,18 @@ _atuin_precmd() {
|
||||||
|
|
||||||
__atuin_history() {
|
__atuin_history() {
|
||||||
# shellcheck disable=SC2048,SC2086
|
# shellcheck disable=SC2048,SC2086
|
||||||
HISTORY="$(ATUIN_LOG=error atuin search $* -i -- "${READLINE_LINE}" 3>&1 1>&2 2>&3)"
|
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__:}
|
||||||
|
|
||||||
|
eval "$HISTORY"
|
||||||
|
else
|
||||||
|
READLINE_LINE=${HISTORY}
|
||||||
|
READLINE_POINT=${#READLINE_LINE}
|
||||||
|
fi
|
||||||
|
|
||||||
READLINE_LINE=${HISTORY}
|
|
||||||
READLINE_POINT=${#READLINE_LINE}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ -n "${BLE_VERSION-}" ]]; then
|
if [[ -n "${BLE_VERSION-}" ]]; then
|
||||||
|
|
Loading…
Reference in a new issue