0

For some reason, I don't have a history of commands in the terminal and neither can I complete paths or commands. Pressing arrows also show symbols like ^[[D and ^[[C.

The shell is bash and .bashrc exists with the necessary autocompletion config.

Results of some outputs:

echo $SHELL: /bin/bash
echo $PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
echo $HISTFILE: 
echo $HISTSIZE: 
echo $HISTFILESIZE: 
echo $TERM: xterm-256color

Also my username and pwd aren't shown before the $ or #.

10
  • How did you determine that the shell is bash? what is the output of echo $0? Feb 21, 2020 at 15:16
  • Also of interest echo $SHELL;echo $PATH;echo $HISTFILE;echo $HISTSIZE;echo $HISTFILESIZE;echo $TERM. Remember to Edit (askubuntu.com/posts/1212119/edit ) your Question to add the information, DO NOT add it in comments.
    – waltinator
    Feb 21, 2020 at 15:25
  • @steeldriver by using echo $SHELL. Result of your command is the same: /bin/bash
    – aardbol
    Feb 21, 2020 at 18:16
  • @waltinator Added as requested
    – aardbol
    Feb 21, 2020 at 18:19
  • Have you messed with any readline-related shell options? what is the output of set +o | grep -w 'vi\|emacs'? Feb 21, 2020 at 18:50

2 Answers 2

0

By not having HISTFILE and HISTSIZE/HISTFILEZISE undefined, you have told bash that you don't want history logging.

Here's how I get one logfile for every bash procss I run:

From ~/.bashrc:

[[ -d ~/.history ]] || mkdir --mode=0700 ~/.history
[[ -d ~/.history ]] && chmod 0700 ~/.history
HISTFILE=~/.history/history.$(date +%y%b%d-%H%M%S).$$
# close any old history file by zeroing HISTFILESIZE  
HISTFILESIZE=0  
# then set HISTFILESIZE to a large value
HISTFILESIZE=4096  
HISTSIZE=4096 
2
  • That doesn't fix it unfortunately. I feel something deeper is responsible which makes all of the above issues appear
    – aardbol
    Feb 22, 2020 at 7:08
  • This does not explain why the control sequences are not being recognized as cursor keys, stated in the second sentence of the question.
    – JdeBP
    Feb 24, 2020 at 9:38
0

You have run, and are currently talking to, the Debian Almquist shell. All of the symptoms match:

  • prompt is $
  • no cursor key control sequence recognition
  • +o vi and +o emacs in the output of set -o
  • no change in response to set -o emacs

The Almquist shell can have line editing. The FreeBSD Almquist shell has it, as does the BusyBox Almquist shell. The Debian Almquist shell lacks it, it not being compiled in. The Debian Almquist shell is deliberately minimal on Ubuntu (and Debian) as about a decade and a half ago Ubuntu and Debian switched /bin/sh over to it, resulting in a significant speedup to many system scripts, precisely because this shell lacked the bells and whistles of other shells.

If you invoked it by running sh, which seems most likely given the value of the SHELL environment variable, exit that shell to be back to your original Bourne Again shell.

Further reading

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .