Skip to content

Commit

Permalink
feat(bash): Add function to reset bash history
Browse files Browse the repository at this point in the history
  • Loading branch information
kpatryk committed Sep 2, 2024
1 parent 1b9d8fc commit 8fa5343
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
29 changes: 29 additions & 0 deletions functions/shell/bash.sh
Original file line number Diff line number Diff line change
@@ -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."
}
2 changes: 0 additions & 2 deletions functions/shell/shfmt.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Functions to work with shfmt

if [[ -n "$ZSH_VERSION" ]]; then
source "$(dirname "$0")/../shared.sh"
else
Expand Down
2 changes: 0 additions & 2 deletions functions/shell/ssh.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Functions to work with SSH

if [[ -n "$ZSH_VERSION" ]]; then
source "$(dirname "$0")/../shared.sh"
else
Expand Down

0 comments on commit 8fa5343

Please sign in to comment.