This article is also available in the following other languages / Dieser Beitrag ist auch in folgenden anderen Sprachen verfügbar: Deutsch

Configure Bash History

2020-01-05 · christian · bash, linux, shell

For Borg Backup I wanted to defined environment variables without adding them to ~/.bash_history. In the man page I found HISTCONTROL.

Default settings on a fresh Debian Buster installation:

borg@borg:~$ set | grep HIST
HISTCONTROL=ignoreboth
HISTFILE=/mnt/backup/borg/.bash_history
HISTFILESIZE=2000
HISTSIZE=1000

HISTCONTROL

This environment variable controls how the executed commands are added to the history file. Multiple settings can be set, separated by a colon.

  • ignorespace: All commands starting with a space will not be added to the history. So you just need to start the environment variable declaration with a space.
  • ignoredups: Prevents adding repeated/duplicate commands to the history
  • erasedups: Remove all duplicate commands from the history before adding the new ones.

Example:

HISTCONTROL="ignorespace:erasedups"
export HISTCONTROL

HISTFILE

Path to the history file.

If undefined, no history is created.

HISTSIZE & HISTFILESIZE

Number of commands which will stored in the history and history file.


More


serverless.industries BG by Carl Lender (CC BY 2.0) Imprint & Privacy
c12dfdfe 2024-03-12 21:53
Mastodon via chaos.social Mastodon via einbeck.social