In the terminal of SFOS 3 I was able to delete commands in the history using for instance history -d 123. Now, using SFOS 4.1, this does not work anymore (while I appreciate that the teminal now remembers commands again)
Have you already tried if deleting the shell history file may work?
rm ~/.ash_history
Thank you for the hint - it does not work. Plus, this would delete the entire history. If I only want to delete some lines (commands) for cleaning up the history a little bit a bash command like history -d
would be nice.
I just tried it out for you:
1. open fingerterm
2. mv .ash_history .ash_history.old
3. close fingerterm
→ history is gone
you can then edit .ash_history.old to your hearts content, after that:
1. open fingerterm
2. cp .ash_history.old .ash_history
3. close fingerterm
-> history is back
Thank you again! I just wonder why removing ask_history did not work for me (after rm ~/.ash_history
it still persisted). I’ll check and tell …
did you actually close fingerterm after having deleted ~/.ash_history
?
Oh yeah, closing and reopening would be the key.
After having removed/renamed the correct shell hist file:
~/.bash_history
Please note the ‘b’…
–edit
or did it change from 3 to 4 (no full bash, just busybox)?
it definitely changed from 3 to 4 … that’s why my old habits do not apply anymore …
you and @unmaintained are right: finally ash_history disappeared (and was created anew with the next fingerterm session). I simply used the file browser to remove the file (instead of rm
from fingerterm). So i might have simply not closed fingerterm …
under 4.1 it is the ash_history (without b) - I suppose because busybox is not bash
If you want it back:
pkcon remove busybox-symlinks-bash
and full blown bash with .bash_history will be back.
Well, because history
is a bash
built-in command and a somewhat of a bashism, it does not exist in ash
(which is part of busybox and SailfishOS’ default shell since v3.4.0).
The solution is, as always, to use the proper UNIX commands as specified by the POSIX standard!
In this specific case this is fc
.
See fc: process the command history list - Linux Man Pages (1p)
or fc(1) [linux man page].
sed -i '/delete-re/d' $HOME/.ash_history
(or $HOME/.bash_history
)
can be used to delete some commands from the history files…
… but after doing that one has to execute exec /bin/true
to
not overwrite the history when shell exit
(note: typoing in exec (I did exec /bin/trye
when testing) will exit the running shell, and the history file gets written)