PROMPT_COMMAND (with current time) breaks cursor position #12060

Open
opened 2026-01-31 03:05:16 +00:00 by claunia · 0 comments
Owner

Originally created by @black-snow on GitHub (Jan 13, 2021).

Environment

Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.19041.0 Microsoft Windows NT 10.0.19041.0

Windows Terminal
Version: 1.4.3243.0

WSL2 Ubuntu 20.x

Steps to reproduce

Set your PROMPT_COMMAND to pretty much anything.

export PROMPT_COMMAND="echo -n \[\$(date +%H:%M:%S)\]\ "

Now use the arrow keys or ctrl+r to go back in history to some earlier command, preferably a long one.
Navigate your cursor left with the home key. (Or arrow up two times+)
Your cursor should now be somewhere before the actual prompt space, somewhere in your path or pc name.

Expected behavior

The cursor should be right after the $.

Actual behavior

Described above. Cursor is not aligned with the visible content.

Originally created by @black-snow on GitHub (Jan 13, 2021). # Environment ```none Platform ServicePack Version VersionString -------- ----------- ------- ------------- Win32NT 10.0.19041.0 Microsoft Windows NT 10.0.19041.0 Windows Terminal Version: 1.4.3243.0 WSL2 Ubuntu 20.x ``` # Steps to reproduce Set your `PROMPT_COMMAND` to pretty much anything. ```bash export PROMPT_COMMAND="echo -n \[\$(date +%H:%M:%S)\]\ " ``` Now use the arrow keys or ctrl+r to go back in history to some earlier command, preferably a long one. Navigate your cursor left with the home key. (Or arrow up two times+) Your cursor should now be somewhere before the actual prompt space, somewhere in your path or pc name. # Expected behavior The cursor should be right after the `$`. # Actual behavior Described above. Cursor is not aligned with the visible content.
claunia added the Issue-QuestionNeeds-Tag-FixResolution-Answered labels 2026-01-31 03:05:16 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#12060