0

SYSTEM:

  • Ubuntu: 20.04
  • Kernel: 5.4.0-162-generic
  • bash: 5.0.17(1)

I found a strange problem that when I use bash's reverse search with CTRL+r, I will find a command I want to run. I select TAB to select it before running, and for some reason bash will insert a string into the command.

Like if the command I want to use is this

(reverse-i-search)`sele': docker exec -it my-postgres psql -P pager=off -P expanded=auto -U database -c "select * from stuff;"

After I hit tab what is presented to me is this

docker exec -it my-postgres psql -P pager=off -P expanded=auto -U database -c "my-select * from stuff;"

see how my- is inserted in front of select? I tried cleaning up my history with -d and writing with -w. But still this behavior continues. It only happens for speific history commands through. So if I did echo dog and reverse searched it, pressed tab, then my- is not inserted. I also tried searching for other words in the command like pager, or auto, and the behavior still happens. On a last note I did try searching for the first word docker, if I hit TAB then, this behavior does not insert my-. Seems to be fine for the first word.

Does anyone know why? I don't do anything crazy with .bashrc here is the only things I added at the end

# User specific aliases and functions
set -o vi
alias lc='stat -c "%A %a %h %U %G %n" * | column -t'
alias vi=vim
export PATH=/home/fsnt/bin:$PATH
export EDITOR='vim'
export VISUAL='vim'

Here is my .inputrc

#vi mode adding TextObject Motions
$if mode=vi
set keymap vi-command
"ciw": "lbcw"
"yiw": "lbyw"
"ciW": "lBcW"
"yiW": "lByW"
$endif
3
  • Don't use tab to select the command. Use esc or Ctrl-J (by default). Tab does completion. (This is true in emacs mode, vi mode may differ). Commented Oct 14, 2023 at 9:43
  • I cant use Ctrl-J. I use that key binding for something else. Is there a way I can use a different key binding? Also where can I find documentation on using bash reverse search? I found this (gnu.org/software/bash/manual/html_node/Searching.html) But it doesn't mention using TAB or what it does actually. Commented Oct 16, 2023 at 13:29
  • That still leaves Escape. You can list the current bindings with bind -p. You can also use a movement key to select the command during search, e.g. I often use C-e (go to end of line) to accept the search as I may want to add something at the end of line. Commented Oct 17, 2023 at 9:07

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.