Dolphin: Disable bash/console history (for directory changing)

In Dolphin, you can open the console by F4 and it (logically) follows the path you are in currently. However, all these cd commands get saved to history. Disabling history (at least for these cd commands) would reduce clutter in the history heavily. The problem however is, that the user might want to save commands which are not cd to history, so unset HISTFILE (which is a workaround but disables history completely) is probably not the best option.

On my system Manjaro KDE, those cd commands are not added to history, if I run history command I don’t see them, and if I press up arrow it prints only the latest cd command.

This would not be a KDE/Dolphin subject but something for the bash project (or other shell you use). Dolphin simply spawns a konsole from F4 and bash (or whatever shell you use) is in charge of the history and how it works.

You can cut a lot of duplication in bash with:

export HISTCONTROL=ignoredups

that squashes consecutive runs of the same command to be just one entry in the history list

When using Dolphin, I have never encountered this issue before. You can notice that Dolphin prevents commands from being recorded in history by adding a space before them. You could try manually entering a command with a leading space to check if such commands are also excluded from your bash history.

This is a distro level bash configuration thing, not specific to Konsole, Dolphin or KDE.
When I first tested KDE Linux, it didn’t hide this, so cd’s were kept in the history. I can’t immediately recall what option I set to stop this annoyance, but it was easily found via search.

HISTIGNORE= should address this. yes it eliminates commands from all history but its relatively straightforward to figure out $PWD based on surrounding context in the history.

e,g, HISTIGNORE=“ls:ll:pwd:cd:which”

You can notice that Dolphin prevents commands from being recorded in history by adding a space before them

That’s the underlying bash shell doing that, you’d only get the ignoring of commands with a initial space if your .bashrc had the HISTCONTROL set to one of either of:
ignorespace
or
ignoreboth

where “ignoreboth” sets both “ignoredups” and “ignorespace” to be active. The default if HISTCONTROL isn’t set is to store all history.

this is the section of the “man bash” I got that from:

HISTCONTROL
    A colon-separated list of values controlling how commands are saved
    on the history list.  If the list of values includes ignorespace, lines
    which begin with a space character are not saved in the history list.
    A value of ignoredups causes lines matching the previous history
    entry to not be saved.  A value of ignoreboth is shorthand  for
    ignorespace  and ignoredups.   A  value of erasedups causes all
    previous lines matching the current line to be removed from the
    history list before that line is saved.  Any value not in the above
    list is ignored.  If HISTCONTROL is unset, or does not include a
    valid value, all lines read by the shell parser are saved
    on the history list, subject to the  value  of  HISTIGNORE.  The second
    and subsequent lines of a multi-line compound command are not
    tested, and are added to the history regardless of the value of
    HISTCONTROL.