

I had one such case recently, turned out it was due to a faulty SATA (data) cable. Once you find which drive is clicking, try plugging it with a new cable before declaring it dead.
dmesg
output may contain some useful error messages. If you find errors related to I/O, block devices, SCSI or SATA, you should include them in your post
https://github.com/atuinsh/atuin is a great tool to manage and search your shell history. I especially enjoy it being able to search commands based on the working directory I was in when I ran them.
It also has more features (which I don’t use) to manage dotfiles and sync shell history across hosts/devices.