From 8fa5343d4af7a515bbb22a52771e63ed22e2e722 Mon Sep 17 00:00:00 2001 From: Patryk Kubiak Date: Mon, 2 Sep 2024 12:03:54 +0200 Subject: [PATCH] feat(bash): Add function to reset bash history --- functions/shell/bash.sh | 29 +++++++++++++++++++++++++++++ functions/shell/shfmt.sh | 2 -- functions/shell/ssh.sh | 2 -- 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 functions/shell/bash.sh diff --git a/functions/shell/bash.sh b/functions/shell/bash.sh new file mode 100644 index 0000000..501cdf9 --- /dev/null +++ b/functions/shell/bash.sh @@ -0,0 +1,29 @@ +if [[ -n "$ZSH_VERSION" ]]; then + source "$(dirname "$0")/../shared.sh" +else + source "$(dirname "${BASH_SOURCE[0]}")/../shared.sh" +fi +prevent_to_execute_directly + +bash_reset_history_and_logs() { + echo "Clearing Bash history..." + history -c + rm -f ~/.bash_history + touch ~/.bash_history + + echo "Reloading the history.." + history -r + + if [ -f ~/.lesshst ]; then + echo "Clearing .lesshst file..." + rm -f ~/.lesshst + fi + if [ -f ~/.viminfo ]; then + echo "Clearing .viminfo file..." + rm -f ~/.viminfo + fi + + echo "History and logs have been cleared." + echo "History has been reloaded in the current session." + echo "For complete effect on all terminals, you may want to log out and log back in." +} diff --git a/functions/shell/shfmt.sh b/functions/shell/shfmt.sh index c56783d..50fb949 100644 --- a/functions/shell/shfmt.sh +++ b/functions/shell/shfmt.sh @@ -1,5 +1,3 @@ -# Functions to work with shfmt - if [[ -n "$ZSH_VERSION" ]]; then source "$(dirname "$0")/../shared.sh" else diff --git a/functions/shell/ssh.sh b/functions/shell/ssh.sh index 86b897d..4a4002c 100644 --- a/functions/shell/ssh.sh +++ b/functions/shell/ssh.sh @@ -1,5 +1,3 @@ -# Functions to work with SSH - if [[ -n "$ZSH_VERSION" ]]; then source "$(dirname "$0")/../shared.sh" else