From cb991a72f910d35162b98170daf23eec77400922 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Sat, 4 Jul 2026 17:36:07 +0530 Subject: [PATCH] Bash: don't add to the database when history is disabled --- CHANGELOG.md | 7 ++++--- templates/bash.txt | 10 +++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 253bc45..9958fe4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,18 +11,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Support for RISC-V (riscv64) Linux. - `import` now supports fetching entries from `atuin`. +- `import` now auto-detects database files. - `import` now skips directories matching `$_ZO_EXCLUDE_DIRS`. - POSIX: support for non-Cygwin Windows environments (e.g. Busybox). - Fish: Space-Tab completions now display and run the selected command. - Bash/POSIX/Zsh: `z` now honors `$CDPATH`. +- Bash: don't add to the database when history is disabled (`set +o history`). +- Nushell: export commands so the init script can be imported with `use`. +- Support for RISC-V (riscv64) Linux. ### Changed - `import` now takes a subcommand instead of the `--from` flag. -- `import` now auto-detects database files. -- Nushell: export commands so the init script can be imported with `use`. ### Fixed diff --git a/templates/bash.txt b/templates/bash.txt index 2244ed7..e5df5c7 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -37,8 +37,10 @@ function __zoxide_cd() { {%- if hook == InitHook::Prompt %} function __zoxide_hook() { \builtin local -r retval="$?" - # shellcheck disable=SC2312 - \command zoxide add -- "$(__zoxide_pwd)" + if [[ -o history ]]; then + # shellcheck disable=SC2312 + \command zoxide add -- "$(__zoxide_pwd)" + fi return "${retval}" } @@ -51,7 +53,9 @@ function __zoxide_hook() { pwd_tmp="$(__zoxide_pwd)" if [[ ${__zoxide_oldpwd} != "${pwd_tmp}" ]]; then __zoxide_oldpwd="${pwd_tmp}" - \command zoxide add -- "${__zoxide_oldpwd}" + if [[ -o history ]]; then + \command zoxide add -- "${__zoxide_oldpwd}" + fi fi return "${retval}" }