.dotfiles/.bash_aliases

194 lines
6.4 KiB
Bash

#!/bin/bash
# My Alias
# Software
# ffmpeg Customs
alias mp4-mp3-folder='for vid in *.mp4; do ffmpeg -i "$vid" -f mp3 -ab 32000 "${vid%.mp4}.mp3"; done'
alias mkv-mp4-folder='for vid in *.mkv; do ffmpeg -i "$vid" -vcodec copy -acodec copy "${vid%.mkv}.mp4"; done'
alias mkv-mp4='mkvmp4(){ ffmpeg -i "$1" -vcodec copy -acodec copy "${1%.mkv}.mp4"; unset -f mkvmp4;}; mkvmp4'
alias mp4-mp3='mp4mp3(){ ffmpeg -i "$1" -f mp3 -ab 32000 "${1%.mp4}.mp3"; unset -f mp4mp3;}; mp4mp3'
# When you get bored
alias telnet-starwars='telnet towel.blinkenlights.nl'
alias nethack-online='ssh nethack@nethack.alt.org ; clear'
alias tron-online='ssh sshtron.zachlatta.com ; clear'
# My IP Info
alias myip='MYIP=$(curl -s http://ipecho.net/plain; echo) && curl ipinfo.io/"$MYIP" && echo'
alias ports-in-use='sudo lsof -i -P -n | grep LISTEN'
# Mis typed whois
alias whosi='whois'
alias gti='git'
alias dc='cd'
# untar
alias untar='tar xvf'
#amass
alias amass-subdomain='domain(){ amass enum -passive -d "$1" >> /opt/amass-scans/"$1".txt; unset -f domain;}; domain'
#SAV Command
alias sav-start='sudo service sav-protect start'
alias sav-stop='sudo service sav-protect stop'
# wget Shortcuts
alias get-nordserverlist="wget https://downloads.nordcdn.com/configs/archives/servers/ovpn.zip"
# Make Life Easier
alias wireshark-pfsense="sudo su -c 'wireshark -k -i <(ssh root@192.168.0.3 -p 2222 tcpdump -i lagg0 -U -w - )'"
alias wireshark-pfsense-lab="sudo su -c 'wireshark -k -i <(ssh root@10.74.85.11 -p 2222 tcpdump -i xn0 host not 192.168.120.27 -U -w - )'"
# Git Functions
function gpm() {
if [ "$(grep -c "[branch "master"]" .git/config )" -gt 0 ]; then
git push origin master
elif [ "$(grep -c "[branch "main"]" .git/config )" -gt 0 ]; then
git push origin main
else
echo "fatal: not a git repository (or any of the parent directories): .git"
fi
}
function gac() {
if [ -d ".git" ]; then
echo "Log Message: "
read logmessage
git add --all && git commit --allow-empty-message -m "$logmessage"
else
echo "No .git Folder found in Directory. Are you in the Correct Folder?"
fi
}
# Pull all Git repos in this dir
function pullall() {
for dir in * ; do
# Execute in subshell
(
cd "$dir" || exit 1
# If it's a git directory, then update it
if test -d .git; then
# Check if its Master or Main
if [ "$(grep -c -i ""master"" .git/config )" -gt 0 ]; then
echo "$dir is a Git repo. Pulling master branch..." && git checkout master && git pull && echo ""
elif [ "$(grep -c -i ""main"" .git/config )" -gt 0 ]; then
echo "$dir is a Git repo. Pulling main branch..." && git checkout main && git pull && echo ""
fi
else
echo "$dir is not a Git repo." && echo ""
fi
)
done
}
# Updates packages from all sources
function update() {
sudo -v
# if command -v snap >/dev/null; then
# echo "Updating Snaps..."
# sudo snap refresh
if [[ -f "/usr/local/bin/snap" ]];then
echo "Updating Snaps..."
sudo snap refresh
else
echo ""
fi
if [ "$(grep -c "debian" /etc/os-release)" -gt 0 ]; then
echo "Updating Apt Packages..."
if [ -d "/opt/sophos-av" ];then
sudo service sav-protect stop >> /dev/null
sudo apt clean && sudo apt update && sudo apt --autoremove full-upgrade -y
sudo service sav-protect start >> /dev/null
else
sudo apt clean && sudo apt update && sudo apt --autoremove full-upgrade -y
fi
elif [ "$(grep -c "arch" /etc/os-release)" -gt 0 ]; then
echo "Updating Pacman Packages"
if [ -d "/opt/sophos-av" ];then
sudo service sav-protect stop >> /dev/null
sudo pacman -Syy -y $$ sudo pacman -Syu -y && sudo pacman --noconfirm -R $(pacman -Qdtq)
sudo service sav-protect start >> /dev/null
else
pacmanorphan=$(sudo pacman -Qdt)
sudo pacman -Syy -y && sudo pacman -Syu -y && sudo pacman --noconfirm -R $(pacman -Qdtq)
fi
else
echo "No apt or pacman found. I guess you're out of luck"
fi
}
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1="\[\033[0;31m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] && echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]root\[\033[01;33m\]@\[\033[01;96m\]\h'; else echo '\[\033[0;39m\]\u\[\033[01;33m\]@\[\033[01;96m\]\h'; fi)\[\033[0;31m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;31m\]]\n\[\033[0;31m\]\342\224\224\342\224\200\342\224\200\342\225\274 \[\033[0m\]\[\e[01;33m\]\\$\[\e[0m\]"
else
PS1='┌──[\u@\h]─[\w]\n└──╼ \卌\n'
fi
# Set 'man' colors
if [ "$color_prompt" = yes ]; then
man() {
env \
LESS_TERMCAP_mb=$'\e[01;31m' \
LESS_TERMCAP_md=$'\e[01;31m' \
LESS_TERMCAP_me=$'\e[0m' \
LESS_TERMCAP_se=$'\e[0m' \
LESS_TERMCAP_so=$'\e[01;44;33m' \
LESS_TERMCAP_ue=$'\e[0m' \
LESS_TERMCAP_us=$'\e[01;32m' \
man "$@"
}
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\033[0;31m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] && echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]root\[\033[01;33m\]@\[\033[01;96m\]\h'; else echo '\[\033[0;39m\]\u\[\033[01;33m\]@\[\033[01;96m\]\h'; fi)\[\033[0;31m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;31m\]]\n\[\033[0;31m\]\342\224\224\342\224\200\342\224\200\342\225\274 \[\033[0m\]\[\e[01;33m\]\\$\[\e[0m\]"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi