Manjaro KDE 18.0.4 .bash_history file in Home directory autopopulates with commands that I did not type and use

When I open the Konsole terminal app and press the Up arrow key to see the commands that I have typed earlier that are saved in the history file, some commands which I did not type always appear. The commands are:

cd /
export TERM=xterm
clear

The commands are always repopulated in the .bash_history file every time I clear the bash_history file log out and then log in or restarting and opening the Konsole app. Uninstalling and Reinstalling Konsole app does not fix this problem. Below is a screenshot of the .bash_history file after clearing the file, uninstalling and reinstalling Konsole, rebooting and opening the Konsole app and not typed and executed any command.

I can confirm that. I've been seeing this at my end here as well, and like you, I have no idea where they come from. :thinking:

I saw in an other thread someone asking about how to remove the new terminal within octopi because it was filling its bash history. Then I guess it comes from octopi
But it's just a guess.

1 Like

I don't think so because I haven't been using Octopi for updating anymore for quite some time now. I now always update by way of a virtual console, while completely logged out of Plasma.

I understand.. but If you still have octopi or its notifier I would just try to remove them just to confirm it's not coming from them.. as you don't really use it (I don't too).

If after you still have the same behaviour then we can search other possibilities

Well that's non sequitur, really. The mechanism Octopi uses for communicating with the notifier does not employ GNU Bash or any other command-line shell.

Furthermore, I need Octopi's notifier because when there's an update, then it takes much longer for my local mirrors to fully sync, and the notifier lets me know when it is safe to update. :wink:

Well .. for less exact results I can volunteer this:
It doesnt happen here and I dont use any notifiers or octopi

1 Like

I was not suggesting you to remove them forever.. just to try to see if it was them.

The trace in your bash suggest a kind of initialisation of octopi terminal.. I don't know how and when it's done

Well, here's some additional info then... When I clear out the shell history, like so...

history -c && > ~/.bash_history

... and I log into a character-mode virtual console, then those commands are there again as well.

One of the properties of Bourne-type shells is that you can execute commands without that they be added to the history, and this is usually done by inserting a space character before the command in question.

Dolphin uses this technique to not store its own Bash commands to the history when you're using the built-in terminal and you click on a different directory (folder). So the cd command that the built-in terminal then executes in order to synchronize the working directory of the shell with that of the Dolphin GUI is not normally stored in the shell's history file.

However, Manjaro does not enable this by default. You have to add..

export HISTIGNORE="[ \t]*"

... to your .bash_profile ─ which I've done. But I suspect there's something somewhere that injects those three commands the OP has reported and that I am seeing as well, and that whatever does this, it's not prefixing those commands with spaces, as it should. :thinking:

It is Octopi, every time it starts it runs those three commands in it's built in terminal. If you use it to install or upgrade things you'll get these commands too

sudo /usr/lib/octopi/octopi-helper -t
bash -c "/tmp/.qt_temp_octopi_*"

As a workaround you can add this line to your ~/.bashrc file

export HISTIGNORE='cd /:export TERM=xterm:clear:sudo /usr/lib/octopi/octopi-helper -t:bash -c "/tmp/.qt_temp_octopi_*"'

But it would be nice if the dev adds a space before those command so that they could be ignored the simpler way using the standard

export HISTCONTROL=ignoreboth:erasedups

ignoreboth : ignores leading spaces and consecutive duplicates
erasedups : removes duplicates of entered command from history


5 Likes

I thank everyone for their input. Noticed that when I start Octopi, those commands I stated are added to the history file. The commands are also added to the file when the PC has booted. I use Octopi because of Pamac issues in KDE like the desktop sometimes loads slower and the error Filesystem mounted at '/' is not responding and when performing a full system upgrade, the last package that it downloads takes too long to download at 1kbps while the Internet connection is fast, all other packages download fast or it does not download the last package and does not proceed from there. And when performing a system upgrade together with AUR updates, Pamac seems to download some dependencies in form of a loop. I now use yay aur helper for updating both the packages in the repositories and the AUR. Added the line that @saedlar93 suggested and it works.