-
-
Save linwiz/c6aa07b648c0d861bf12 to your computer and use it in GitHub Desktop.
CLR
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Clear screen, history and trunicate files | |
_clrTabComplete() { | |
local cur | |
COMPREPLY=() | |
cur=${COMP_WORDS[COMP_CWORD]} | |
COMPREPLY=( $( compgen -W 'normal full log sulog help' -- $cur ) ) | |
return 0 | |
} | |
complete -F _clrTabComplete clr | |
_clr_help() { | |
echo "Usage: clr [option]" | |
echo "help - This file" | |
echo "normal - Clear screen and tmux history" | |
echo "full - Clear screen, tmux history and bash history" | |
echo "log - Trunicate a file/log" | |
echo "sulog - Trunicate a file/log with sudo" | |
} | |
clr() { | |
if [[ "$1" == "help" ]] | |
then | |
_clr_help | |
elif [[ "$1" == "normal" ]] | |
then | |
clear && tmux clear-history | |
elif [[ "$1" == "full" ]] | |
then | |
clear && tmux clear-history && history -c | |
elif [[ "$1" == "log" ]] | |
then | |
if [[ -z "$2" ]] | |
then | |
echo "Please include a file." | |
_clr_help | |
elif [[ ! -f "$2" ]] | |
then | |
echo "File Does not exist: $2" | |
_clr_help | |
else | |
dd if=/dev/null of="$2" | |
fi | |
elif [[ "$1" == "sulog" ]] | |
then | |
if [[ -z "$2" ]] | |
then | |
echo "Please include a file." | |
_clr_help | |
elif [[ ! -f "$2" ]] | |
then | |
echo "File Does not exist: $2" | |
_clr_help | |
else | |
sudo dd if=/dev/null of="$2" | |
fi | |
elif [[ -z "$1" ]] | |
then | |
clear && tmux clear-history | |
else | |
echo "Unknown command: $1" | |
_clr_help | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment