Bash History Not Working

Hi,
I used in Bash to type part of the commands issued earlier so it gives me automatically the rest of the command or I can scroll up to previous commands with the part I type.

Not anymore. Sure I did it while playing with my system. But don’t know what did it, or how to have it again.

Any help highly appreciated.

Can we see your .bashrc?

Sure. As usual @dalto is there for the recue!

#
# /etc/bash.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

[[ $DISPLAY ]] && shopt -s checkwinsize

PS1='[\u@\h \W]\$ '

case ${TERM} in
  xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
    PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'

    ;;
  screen*)
    PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
    ;;
esac

[ -r /usr/share/bash-completion/bash_completion   ] && . /usr/share/bash-completion/bash_completion
alias ocr="bash /home/limo/Software/MyScripts/ocr.sh"
alias addalias="bash /home/limo/Software/MyScripts/addalias.sh"
alias checkpdf="bash /home/limo/Software/MyScripts/checkpdf.sh"

Hmm…what else have you changed?

What does this show:

bind -P

I can’t tell! I was palying a lot, stupidly I believe to be honest!

[limo@lenovo ~]$ bind -P

abort can be found on "\C-g", "\C-x\C-g", "\e\C-g".
accept-line can be found on "\C-j", "\C-m".
alias-expand-line is not bound to any keys
arrow-key-prefix is not bound to any keys
backward-byte is not bound to any keys
backward-char can be found on "\C-b", "\eOD", "\e[D".
backward-delete-char can be found on "\C-h", "\C-?".
backward-kill-line can be found on "\C-x\C-?".
backward-kill-word can be found on "\e\C-h", "\e\C-?".
backward-word can be found on "\e\e[D", "\e[1;3D", "\e[1;5D", "\e[5D", "\eb".
beginning-of-history can be found on "\e<", "\e[5~".
beginning-of-line can be found on "\C-a", "\eOH", "\e[1~", "\e[7~", "\e[H".
bracketed-paste-begin can be found on "\e[200~".
call-last-kbd-macro can be found on "\C-xe".
capitalize-word can be found on "\ec".
character-search can be found on "\C-]".
character-search-backward can be found on "\e\C-]".
clear-display can be found on "\e\C-l".
clear-screen can be found on "\C-l".
complete can be found on "\C-i", "\e\e".
complete-command can be found on "\e!".
complete-filename can be found on "\e/".
complete-hostname can be found on "\e@".
complete-into-braces can be found on "\e{".
complete-username can be found on "\e~".
complete-variable can be found on "\e$".
copy-backward-word is not bound to any keys
copy-forward-word is not bound to any keys
copy-region-as-kill is not bound to any keys
dabbrev-expand is not bound to any keys
delete-char can be found on "\C-d", "\e[3~".
delete-char-or-list is not bound to any keys
delete-horizontal-space can be found on "\e\\".
digit-argument can be found on "\e-", "\e0", "\e1", "\e2", "\e3", ...
display-shell-version can be found on "\C-x\C-v".
do-lowercase-version can be found on "\C-xA", "\C-xB", "\C-xC", "\C-xD", "\C-xE", ...
downcase-word can be found on "\el".
dump-functions is not bound to any keys
dump-macros is not bound to any keys
dump-variables is not bound to any keys
dynamic-complete-history can be found on "\e\C-i".
edit-and-execute-command can be found on "\C-x\C-e".
emacs-editing-mode is not bound to any keys
end-kbd-macro can be found on "\C-x)".
end-of-history can be found on "\e>", "\e[6~".
end-of-line can be found on "\C-e", "\eOF", "\e[4~", "\e[8~", "\e[F".
exchange-point-and-mark can be found on "\C-x\C-x".
forward-backward-delete-char is not bound to any keys
forward-byte is not bound to any keys
forward-char can be found on "\C-f", "\eOC", "\e[C".
forward-search-history can be found on "\C-s".
forward-word can be found on "\e\e[C", "\e[1;3C", "\e[1;5C", "\e[5C", "\ef".
glob-complete-word can be found on "\eg".
glob-expand-word can be found on "\C-x*".
glob-list-expansions can be found on "\C-xg".
history-and-alias-expand-line is not bound to any keys
history-expand-line can be found on "\e^".
history-search-backward is not bound to any keys
history-search-forward is not bound to any keys
history-substring-search-backward is not bound to any keys
history-substring-search-forward is not bound to any keys
insert-comment can be found on "\e#".
insert-completions can be found on "\e*".
insert-last-argument can be found on "\e.", "\e_".
kill-line can be found on "\C-k".
kill-region is not bound to any keys
kill-whole-line is not bound to any keys
kill-word can be found on "\e[3;5~", "\ed".
magic-space is not bound to any keys
menu-complete is not bound to any keys
menu-complete-backward is not bound to any keys
next-history can be found on "\C-n", "\eOB", "\e[B".
next-screen-line is not bound to any keys
non-incremental-forward-search-history can be found on "\en".
non-incremental-forward-search-history-again is not bound to any keys
non-incremental-reverse-search-history can be found on "\ep".
non-incremental-reverse-search-history-again is not bound to any keys
old-menu-complete is not bound to any keys
operate-and-get-next can be found on "\C-o".
overwrite-mode is not bound to any keys
possible-command-completions can be found on "\C-x!".
possible-completions can be found on "\e=", "\e?".
possible-filename-completions can be found on "\C-x/".
possible-hostname-completions can be found on "\C-x@".
possible-username-completions can be found on "\C-x~".
possible-variable-completions can be found on "\C-x$".
previous-history can be found on "\C-p", "\eOA", "\e[A".
previous-screen-line is not bound to any keys
print-last-kbd-macro is not bound to any keys
quoted-insert can be found on "\C-q", "\C-v", "\e[2~".
redraw-current-line is not bound to any keys
re-read-init-file can be found on "\C-x\C-r".
reverse-search-history can be found on "\C-r".
revert-line can be found on "\e\C-r", "\er".
self-insert can be found on " ", "!", "\"", "#", "$", ...
set-mark can be found on "\C-@", "\e ".
shell-backward-kill-word is not bound to any keys
shell-backward-word can be found on "\e\C-b".
shell-expand-line can be found on "\e\C-e".
shell-forward-word can be found on "\e\C-f".
shell-kill-word can be found on "\e\C-d".
shell-transpose-words can be found on "\e\C-t".
skip-csi-sequence is not bound to any keys
start-kbd-macro can be found on "\C-x(".
tab-insert is not bound to any keys
tilde-expand can be found on "\e&".
transpose-chars can be found on "\C-t".
transpose-words can be found on "\et".
tty-status is not bound to any keys
undo can be found on "\C-x\C-u", "\C-_".
universal-argument is not bound to any keys
unix-filename-rubout is not bound to any keys
unix-line-discard can be found on "\C-u".
unix-word-rubout can be found on "\C-w".
upcase-word can be found on "\eu".
vi-append-eol is not bound to any keys
vi-append-mode is not bound to any keys
vi-arg-digit is not bound to any keys
vi-back-to-indent is not bound to any keys
vi-backward-bigword is not bound to any keys
vi-backward-word is not bound to any keys
vi-bword is not bound to any keys
vi-bWord is not bound to any keys
vi-change-case is not bound to any keys
vi-change-char is not bound to any keys
vi-change-to is not bound to any keys
vi-char-search is not bound to any keys
vi-column is not bound to any keys
vi-complete is not bound to any keys
vi-delete is not bound to any keys
vi-delete-to is not bound to any keys
vi-editing-mode is not bound to any keys
vi-end-bigword is not bound to any keys
vi-end-word is not bound to any keys
vi-eof-maybe is not bound to any keys
vi-eword is not bound to any keys
vi-eWord is not bound to any keys
vi-fetch-history is not bound to any keys
vi-first-print is not bound to any keys
vi-forward-bigword is not bound to any keys
vi-forward-word is not bound to any keys
vi-fword is not bound to any keys
vi-fWord is not bound to any keys
vi-goto-mark is not bound to any keys
vi-insert-beg is not bound to any keys
vi-insertion-mode is not bound to any keys
vi-match is not bound to any keys
vi-movement-mode is not bound to any keys
vi-next-word is not bound to any keys
vi-overstrike is not bound to any keys
vi-overstrike-delete is not bound to any keys
vi-prev-word is not bound to any keys
vi-put is not bound to any keys
vi-redo is not bound to any keys
vi-replace is not bound to any keys
vi-rubout is not bound to any keys
vi-search is not bound to any keys
vi-search-again is not bound to any keys
vi-set-mark is not bound to any keys
vi-subst is not bound to any keys
vi-tilde-expand is not bound to any keys
vi-unix-word-rubout is not bound to any keys
vi-yank-arg is not bound to any keys
vi-yank-pop is not bound to any keys
vi-yank-to is not bound to any keys
yank can be found on "\C-y".
yank-last-arg can be found on "\e.", "\e_".
yank-nth-arg can be found on "\e\C-y".
yank-pop can be found on "\ey".
[limo@lenovo ~]$ 


Just curious, what is

bind -P

and what is the meaning of these results… how to read it. (don’t waste your time if it takes time to reply)

It shows you the command in bash and what keys are mapped to it.

In this case, the one we care about is:

So, the up arrow key is still bound to your previous history item.

That means either you terminal history is no longer working or you terminal emulation has some issue.

I can scroll up and down normally.
But typing “yay” and scrolling up does not give me “yay -Syu” then “yay -Rc xyzapp”

What about restoring an earlier .bashrc? Other files as well from earlier snapshots?

Oh, that is probably history-search-backward. You previously had that bound to up arrow?

Did you make any changes to /etc/inputrc or ~/.inputrc ?

I don’t think so.
So, let me look for them in an old snapshot and try copy/paste them and see. Perhaps boot to an old snapshot and see. Is that OK?

I can now use up arrow, to scroll back to commands I did in back order.

You can add this into your ~/.bashrc:

bind '"\e[A":history-search-backward'      # history with arrow up key
bind '"\e[B":history-search-forward'       # history with arrow down key
2 Likes

Automagically worked as before!
Thank you very much @manuel
Amazing forum and community as usual.

Did you change the default key binding in your profile of konsole ?

Open konsole → Settings → Edit current profile → keyboard → Select XFree 4

1 Like

I have only one profile (“Default”) and it is read only!

Maybe you replaced the original ~/.bashrc which had these bind commands?

1 Like

My +60 y/o brain just remembered I accidentally (wile playing naughty) deleted -a few days ago- all hidden files under /home :hushed:
The same old brain just remembered I copied this .bashrc from somewhere under root.

1 Like

Information about such events is useful background material to anybody trying to help in case of issues.

One way to prepare for such problems is creating backups of $HOME (and any personal data elsewhere) regularly. Then you have a chance to get important information back…

1 Like

I finally have BTRFS Assistant, Snapper… etc. installed and conigured to snapshot /home and I am enjoying it.

The only problem I was totally new then to all this (and still) (on Endeavour for a month, on BTRFS for 13 days, on BTRFS assistant and snapper for about just 4 days!).

So, I will have a backup anyway.

1 Like

Allow me @manuel to ask for another favour.
Previously if I issued e.g. inxi -Fxxz, then later at the prompt I type just “inx” it automagically completes “i -Fxxz” wher I just pres Tab or Right Arrow (can’t remember) to have the full command " inxi -Fxxz"

I don’t have this wonderful feature now.

How can I get it?

Are you sure this was on EOS and not whatever distro you were using previously?

I don’t think we ship command completion in the default config.