Skip to content

Instantly share code, notes, and snippets.

@fahimalizain
Last active August 28, 2021 15:28
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 fahimalizain/1cd8559d1c17857a80b98f9fd5a36efc to your computer and use it in GitHub Desktop.
Save fahimalizain/1cd8559d1c17857a80b98f9fd5a36efc to your computer and use it in GitHub Desktop.
Beautiful bash-alias
# SSH-Agent
## SSH Agent and keys
# set SSH_AUTH_SOCK env var to a fixed value
export SSH_AUTH_SOCK=~/.ssh/ssh-agent.sock
# test whether $SSH_AUTH_SOCK is valid
ssh-add -l 2>/dev/null >/dev/null
# if not valid, then start ssh-agent using $SSH_AUTH_SOCK
if [ $? -ge 2 ]; then
# if sock file exists, let's delete it
if [[ -e "$SSH_AUTH_SOCK" ]]; then
echo "Deleting Old $SSH_AUTH_SOCK"
rm $SSH_AUTH_SOCK
fi
ssh-agent -a "$SSH_AUTH_SOCK" >/dev/null
ssh-add /home/fahimalizain/.ssh/faztp-msi-gl73
fi
# COLORS!
export RED='\033[0;31m'
export GREEN='\033[0;32m'
export BLUE='\033[0;34m'
export DARK_GRAY='\033[1;30m'
export YELLOW='\033[1;33m'
export NC='\033[0m' # No Color
make_alias() {
echo -e "\tALIAS\t${RED}$1\n\t\t${DARK_GRAY}$2${NC}"
alias $1="echo -e \"\n\t${DARK_GRAY}\$$2${NC}\n\" && $2"
}
make_alias ls_listen 'sudo lsof -iTCP -sTCP:LISTEN'
make_alias cpu_watch "watch -n 1 '(sensors | grep Core); (cat /proc/cpuinfo | grep MHz);'"
make_alias my_ip "curl ipinfo.io"
make_alias wsl2_drop_cache 'echo 3 | sudo tee /proc/sys/vm/drop_caches'
make_alias wsl2_compact_memory 'echo 1 | sudo tee /proc/sys/vm/compact_memory'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment