Removing Shell History

Hello, all
If tiered of Removing Terminal histroy try this script

#!/bin/bash

echo "#!/bin/bash

# Clear the screen
clear

# Attention
echo \" Running as \$USER\"

# Animated title
figlet -f speed 'Clear Shell History' | lolcat

# Message
echo ''
echo \"Confirm to clear the entier shell history
    1. Confirm [1]
    2. Cancle & Exit  [0]\"

# User Input
read user_confirm

if [[ \$user_confirm -eq 1 ]]; then

cd /home/$USER

# Clear all the history from bash prompt @ .bash_history
    echo '' > .bash_history

# Clear fish_history file
    echo '' > .local/share/fish/fish_history

# Exit
    echo ''
    echo \"Press [Enter] to Exit\"
    read user_exit
    exit
else
    if [[ \$user_confirm -eq 0 ]]; then
        exit
    fi
fi" > /tmp/history_clear_confirm.sh

# Run as root
echo "#!/bin/bash

# Mode
echo 'Run as Root ? [1,0]'
read user_root
echo ''
if [[ \$user_root -eq 1 ]]; then
    sudo sh /tmp/history_clear_confirm.sh
else
    if [[ \$user_root -eq 0 ]]; then
        sh /tmp/history_clear_confirm.sh
    fi
fi" > /tmp/root_history_clear_confirm.sh

# Changing Permissions
chmod u+x /tmp/root_history_clear_confirm.sh
chmod u+x /tmp/history_clear_confirm.sh

# Executing in konsole
konsole -e sh /tmp/root_history_clear_confirm.sh

# Removing Cache files
rm tmp/history_clear_confirm.sh
rm root_history_clear_confirm.sh

Any corrections or suggestions to make it better :grin:

1 Like

There is already a thread to share handy scrupts :wink:

2 Likes

This is why people shouldn't make YouTube videos.

The answer here is history -c .

3 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.