Skip to content

Commit

Permalink
fix(shell): fix incorrect timing of child shells (#1510)
Browse files Browse the repository at this point in the history
When a child shell session is started from another shell session
(parent session), the environment variable ATUIN_HISTORY_ID set by the
parent session causes Atuin's precmd hook of the child session to be
unexpectedly performed before the first call of Atuin's preexec hook.

In this patch, we clear ATUIN_HISTORY_ID (possibly set by the parent
session) on the startup of the session.
  • Loading branch information
akinomyoga committed Jan 8, 2024
1 parent 7e48768 commit cc5efd2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions atuin/src/shell/atuin.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ATUIN_SESSION=$(atuin uuid)
ATUIN_STTY=$(stty -g)
export ATUIN_SESSION
ATUIN_HISTORY_ID=""

__atuin_preexec() {
if [[ ! ${BLE_ATTACHED-} ]]; then
Expand Down
1 change: 1 addition & 0 deletions atuin/src/shell/atuin.fish
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set -gx ATUIN_SESSION (atuin uuid)
set --erase ATUIN_HISTORY_ID

function _atuin_preexec --on-event fish_preexec
if not test -n "$fish_private_mode"
Expand Down
1 change: 1 addition & 0 deletions atuin/src/shell/atuin.nu
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Source this in your ~/.config/nushell/config.nu
$env.ATUIN_SESSION = (atuin uuid)
hide-env -i ATUIN_HISTORY_ID

# Magic token to make sure we don't record commands run by keybindings
let ATUIN_KEYBINDING_TOKEN = $"# (random uuid)"
Expand Down
1 change: 1 addition & 0 deletions atuin/src/shell/atuin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ else
fi

export ATUIN_SESSION=$(atuin uuid)
ATUIN_HISTORY_ID=""

_atuin_preexec() {
local id
Expand Down

1 comment on commit cc5efd2

@vercel
Copy link

@vercel vercel bot commented on cc5efd2 Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

atuin-docs – ./

atuin-docs-git-main-atuin.vercel.app
atuin-docs-atuin.vercel.app
atuin-docs.vercel.app

Please sign in to comment.