Command history in terminal

Using terminal in plasma, how can I increase the number of commands retained in history.

Currently, it appears to save 10. In other distros, I have hundreds, which is great for people, like me, with terrible recall…instead of total recall.

Hi @drmacro,

Please post the output of:

echo $SHELL

For bash, you do this by setting (and exporting) the $HISTSIZE variable. This is usually done in ~/.bash_profile. :arrow_down:

[nx-74205:/dev/pts/3][/home/aragorn]
[aragorn] >  cat .bash_profile 
#
# ~/.bash_profile
#

[[ -f ~/.bashrc ]] && . ~/.bashrc
[[ -f ~/.profile ]] && . ~/.profile
EDITOR=/usr/bin/nano
HISTCONTROL=ignoreboth:erasedups
HISTSIZE=1000
HISTIGNORE='[ \t]*'
export EDITOR HISTCONTROL HISTSIZE HISTIGNORE

For zsh, I’m not sure, but it may use the same mechanism. However, I do not have a ~/.zprofile in my home directory, so I’m guessing that the $HISTSIZE is set in /usr/share/zsh/manjaro-zsh-config.

You should however be able to set it in ~/.zshrc, like so… :arrow_down:

export HISTSIZE=1000

Do however keep in mind that the settings for bash and zsh do not affect each other. They are different shells, and they run in different environments.

3 Likes

I think the command history shows only the last ten, but there are more. Try typing history 1 instead. You can see the whole history with cat ~/.zhistory.

I would indeed be surprised if the default configuration were to only retain the last 10 commands. However, I have almost no experience with zsh — I use bash. :wink:

1 Like

Never used it before, but it shows 16 for me.

It definitely retains more, assuming there isn’t something else overriding this.

# /usr/share/zsh/manjaro-zsh-config
HISTFILE=~/.zhistory
HISTSIZE=10000
SAVEHIST=10000
2 Likes

It’s true, I said it without testing it and shows 16, not 10. :+1:

@drmacro is probably typing history alone and that’s why thinks the history is so short. Zsh’s history shows last 16 commands, history n shows history from n to the end and history -n shows last n commands, so better type history 1 to see the whole history.

2 Likes