Current path not reflected in bash prompt

Hello all,
This is just a slight annoyance: the current directory does not seem to be immediately reflected in bash prompt (PS1) upon selection from Atuin history.

Repro steps

  1. run bash with Atuin as usual
  2. export PS1='\w> '
  3. Ctrl-R to search in Atuin history and choose some cd <exisiting_folder> and Enter
  4. now observe: your prompt has not changed but pwd returns <exisiting_folder> as expected
  5. press only Enter alone and now you can see the prompt changed to <exisiting_folder>

My hunch is it is some bash/pre-exec behaviour as $PWD is changed, just not reflected in PS1.

When tested in zsh, all is as expected: path is changed and reflected in PS1 at the same time (tested with PS1='%~> ').

My env

I thought it could be related to using starship but it is not; nor was the choice of terminal emulators (tested with Tilix and GNOME Terminal).

Some system info:

$cat /etc/os-release | grep PRET
PRETTY_NAME="Ubuntu 24.04.2 LTS"

Atuin Doctor
Checking for diagnostics


Please include the output below with any bug reports or issues

{
  "atuin": {
    "version": "18.7.1",
    "sync": {
      "cloud": false,
      "records": true,
      "auto_sync": true,
      "last_sync": "2025-08-01 10:30:38.569162526 +00:00:00"
    },
    "sqlite_version": "3.46.0"
  },
  "shell": {
    "name": "bash",
    "default": "bash",
    "plugins": [
      "atuin",
      "bash-preexec"
    ],
    "preexec": "bash-preexec"
  },
  "system": {
---snip

Thanks,
slavos1

I suspect this is an artifact of bash-preexec messing with PS1/prompt. @akinomyoga would know better, but I’d suggest trying ble.sh and see if the issue still occurs

This isn’t related to the implementation of bash-preexec, but this is related to how Atuin handles the enter_accept feature in Bash without ble.sh. If it is not in ble.sh, Atuin tries to run the command with a shell function __atuin_accept_line that emulates the behavior of the execution of the command by Bash. However, it is still an emulation and Bash/Readline doesn’t recognize that a user command was run. Then, the prompt is not updated. Bash/Readline only updates the content of the prompt when the current prompt is first rendered, so the directory paths in the prompt before enter_accept are preserved. With Bash/Readline, I’m not aware of any solution to this problem other than actually running a user command in a normal way.

There is no such problem with ble.sh because Atuin can use the ble.sh’s widget accept-line to run the command in a proper way for enter_accept.

2 Likes

To reproduce the issue with a simple setup (without Atuin or bash-preexec), you can try the following:

$ HISTFILE=/dev/null bash --norc    # <-- start a plain Bash session
$ PS1='\w\$ '
$ bind -x '"\C-t": cd /usr/bin'
$ <press C-t>

Then, you can observe that the path in the prompt is not updated (until going to the next prompt) even though the actual working directory has already been moved to /usr/bin.

2 Likes

Thanks @akinomyoga for the detailed explanation, appreciate your time. It’s an interesting quirk; maybe I’ll try ble.sh or just live with pressing Enter again after Ctrl-R+Enter. :slight_smile: