I add to ~/.bashrc the following code:

test_exclamation () {
  printf %s "$READLINE_LINE" | xargs echo
bind -x '"\eX": test_exclamation'

I write to bash prompt buffer

$ !1700

If I press Enter, then command with number 1700 from history performs. If I press Shift+Alt+X, I got an output:


How to change test_exclamation function to print command under number 1700?


1 Answer 1


Change it to

test_exclamation () {   READLINE_LINE=$( history -p "$READLINE_LINE" ) ;  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.