Skip to content

Edited commands after Right arrow paste are not saved to history #205

Description

@stoicflame

Description

When using RESH search (Ctrl+R), selecting a command, pressing Right arrow to paste it to the command line, editing the pasted command, and then executing it, the edited command is not saved to history. Only the original (unedited) command that was pasted appears in history.

Steps to Reproduce

  1. Start a bash session with RESH installed
  2. Execute some test commands (e.g., echo "test1", echo "test2")
  3. Press Ctrl+R to open RESH search
  4. Find and select a previous command
  5. Press Right arrow to paste the command into the readline buffer (instead of Enter)
  6. Edit the pasted command (e.g., change echo "test1" to echo "test3")
  7. Press Enter to execute the edited command
  8. Search history again - the edited command is missing

Expected Behavior

The edited command (e.g., echo "test3") should be saved to RESH history after execution.

Actual Behavior

Only the original pasted command appears in history. The edited version is not captured by RESH.

System Information

  • RESH version: 3.0.2
  • Bash version: GNU bash, version 5.2.21(1)-release (x86_64-pc-linux-gnu)
  • OS: Linux 6.17.0-20-generic
  • bash-preexec: Installed at ~/.bash-preexec.sh

Configuration

  • BindControlR: true
  • bash-preexec is sourced before RESH shellrc in ~/.bashrc
  • Functions registered: preexec_functions=(__resh_preexec), precmd_functions=(__resh_precmd)

Analysis

Looking at ~/.resh/hooks.sh (lines 109-113), there's a comment about bash-preexec widget interaction issues:

# This is a very bad workaround.
# Force bash-preexec to run repeatedly because otherwise premature run 
# of bash-preexec overshadows the next proper run.
# I honestly think that it's impossible to make widgets work in bash without hacks like this.
__bp_preexec_interactive_mode="on"

This suggests there may be a known issue with how bash-preexec captures commands that are pasted via the RESH widget and then edited before execution.

Workaround

Using Enter to execute commands directly from RESH search (instead of Right arrow) works correctly and saves to history.

Question

Is there a configuration option or fix to ensure edited pasted commands are captured? Or is this a limitation of the bash-preexec/readline integration?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions