Skip to content

Instantly share code, notes, and snippets.

@marhensa
Last active August 28, 2023 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marhensa/c8a8cdd659d3cfa23c1d3ab7fe3c9993 to your computer and use it in GitHub Desktop.
Save marhensa/c8a8cdd659d3cfa23c1d3ab7fe3c9993 to your computer and use it in GitHub Desktop.
Bash Linux - clear screen and clear all bash histories and back to home folder
history -c && history -w && clear && cd ~
@marhensa
Copy link
Author

marhensa commented Aug 28, 2023

to make an alias, so it could be run in a single simple command: clearall

if grep -q "alias clearall" ~/.bashrc; then
    sed -i '/alias clearall/d' ~/.bashrc
fi

cat <<EOF >> ~/.bashrc
alias clearall='history -c && history -w && clear && cd ~'
EOF

source ~/.bashrc

clear && echo "Now 'clearall' is a command to clear all bash histories and back to home folder."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment