# COMPRESSION
alias untargz='tar --same-owner -zxvf'
alias untarbz='tar --same-owner -xjvf'
alias lstargz='tar -ztvf'
alias lstarbz='tar -jtvf'
alias targz='tar -zcvf'
alias tarbz='tar -cjvf'

# NAVIGATION
alias cd..='cd ..'
alias ..='cd ..'
alias ...='cd ../..'
alias .3='cd ../../..'
alias .4='cd ../../../..'
alias .5='cd ../../../../..'

# SYNC AND COPY
alias scp='scp -r'
alias rsynce='sudo rsync -avzh --progress --force --delete --exclude-from $HOME/docker/shared/config/rsync-exclude'
alias rsyncne='sudo rsync -avzh --progress --force --delete'
# native copy
alias cp='sudo rsync -avzh --info=progress2'
# copy files with rsync
alias mv='sudo rsync -avzh --info=progress2 --remove-source-files'
# move files with rsync
alias mvn='mv --verbose'
# native move

# SEARCH AND FIND
alias gh='history|grep'
# search bash history
alias findr='sudo find / -name'
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'

# TRASH - trash-cli
alias rm='trash-put'
alias rmv='rm -rv'
alias tempty='trash-empty ; sudo trash-empty ; sudo -H trash-empty'
alias tlist='trash-list'
alias srmt='sudo trash-put'

# FILE SIZE AND STORAGE
alias uuid='sudo vol_id -u'
alias ls='ls -F --color=auto --group-directories-first'
alias ll='ls -alh --color=auto --group-directories-first'
alias lt='ls --human-readable --color=auto --size -1 -S --classify'
# file size sorted
alias lsr='ls --color=auto -t -1'
# recently modified
alias mnt='mount | grep -E ^/dev | column -t'
# show mounted drives
alias dirsize='sudo du -hx --max-depth=1'
alias dirusage='du -ch | grep total'
# Grabs the disk usage in the current directory
alias diskusage='df -hl --total | grep total'
# Gets the total disk usage on your machine
alias partusage='df -hlT --exclude-type=tmpfs --exclude-type=devtmpfs'
# Shows the individual partition usages without the temporary memory values
alias usage10='du -hsx * | sort -rh | head -10'
# Gives you what is using the most space. Both directories and files. Varies on current directory

# BASH ALIASES
alias baupdate='. ~/.bashrc'
alias baedit='nano $HOME/.bash_aliases'
alias bacopy='sudo cp $HOME/.bash_aliases* /root/'
alias baget='curl -s https://raw.githubusercontent.com/htpcBeginner/docker-traefik/master/shared/config/bash_aliases -o /$HOME/.bash_aliases >/dev/null 2>&1'

# GIT AND SITE MANAGEMENT
alias gcpush='echo "Usage: gcpush ../commits/date.txt" ; cd $HOME/docker ; bash scripts/github/doccheck.sh'
# To push my files to docker-traefik repo
alias gpush='cd $HOME/docker ; git push'
alias ggraph='git log --all --decorate --oneline --graph'

# MAIL SERVER TESTING
alias tmail1='echo -e "### `date +'\''%Y-%m-%d %H:%M'\''` ### \n\n This is a mail server test using tmail1 alias." | mail -s "tmail1 from $HOSTNAME" info@$PRIMARY_DOMAIN -aFrom:$HOSTNAME@$PRIMARY_DOMAIN'
alias tmail2='echo -e "### `date +'\''%Y-%m-%d %H:%M'\''` ### \n\n This is a mail server test using tmail2 alias. It needs and email id after the tmail2 command." | mail -s "tmail2 from $HOSTNAME"'

# SYSTEMD START, STOP AND RESTART
alias ctlreload='sudo systemctl daemon-reload'
alias ctlstart='sudo systemctl start'
alias ctlstop='sudo systemctl stop'
alias ctlrestart='sudo systemctl restart'
alias ctlstatus='sudo systemctl status'
alias ctlenable='sudo systemctl enable'
alias ctldisable='sudo systemctl disable'
alias ctlactive='sudo systemctl is-active'

alias shellstart='ctlstart shellinabox'
alias shellstop='ctlstop shellinabox'
alias shellrestart='ctlrestart shellinabox'
alias shellstatus='ctlstatus shellinabox'

alias sshstart='ctlstart ssh'
alias sshstop='ctlstop ssh'
alias sshrestart='ctlrestart ssh'
alias sshstatus='ctlstatus ssh'

alias ufwstart='ctlstart ufw'
alias ufwstop='ctlstop ufw'
alias ufwrestart='ctlrestart ufw'
alias ufwstatus='ctlstatus ufw'

alias webminstart='ctlstart webmin'
alias webminstop='ctlstop webmin'
alias webminrestart='ctlrestart webmin'
alias webminstatus='ctlstatus webmin'

alias nfsstart='ctlstart nfs-kernel-server'
alias nfsstop='ctlstop nfs-kernel-server'
alias nfsrestart='ctlrestart nfs-kernel-server'
alias nfsstatus='ctlstatus nfs-kernel-server'
alias nfsreload='sudo exportfs -a'

# INSTALLATION AND UPGRADE
alias update='sudo apt-get update'
alias upgrade='sudo apt-get update && sudo apt-get upgrade'
alias install='sudo apt-get install'
alias finstall='sudo apt-get -f install'
alias rinstall='sudo apt-get -f install --reinstall'
alias uninstall='sudo apt-get remove'
alias search='sudo apt-cache search'
alias addkey='sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com'

# SHUTDOWN AND RESTART
alias shutdown='sudo shutdown -h now'
alias reboot='sudo reboot'

# NETWORKING
alias portsused='sudo netstat -tulpn | grep LISTEN'
alias showports='netstat -lnptu'
alias showlistening='lsof -i -n | egrep "COMMAND|LISTEN"'
alias ping='ping -c 5'
alias ipe='curl ipinfo.io/ip'
# external ip
alias ipi='ipconfig getifaddr en0'
# internal ip
alias header='curl -I'
# get web server headers

# SYNOLOGY DSM COMMANDS
alias servicelist='sudo synoservicecfg --list'
# does not work in DSM 7
alias servicestatus='sudo synosystemctl status'
alias servicestop='sudo synosystemctl stop'
alias servicehstop='sudo synoservicecfg --hard-stop'
# does not work in DSM 7
alias servicestart='sudo synosystemctl start'
alias servicehstart='sudo synoservicecfg --hard-start'
# does not work in DSM 7
alias servicerestart='sudo synosystemctl restart'
alias restartdocker='sudo synosystemctl restart pkgctl-Docker'

# MISCELLANEOUS
alias wget='wget -c'
alias nano='sudo nano -iSw$'
alias scxterm='bash $HOME/docker/scripts/xterm.sh'

# SYSTEM MONITORING
alias meminfo='free -m -l -t'
# memory usage
alias psmem='ps auxf | sort -nr -k 4'
# get top process eating memory
alias psmem10='ps auxf | sort -nr -k 4 | head -10'
# get top process eating memory
alias pscpu='ps auxf | sort -nr -k 3'
# get top process eating cpu
alias pscpu10='ps auxf | sort -nr -k 3 | head -10'
# get top process eating cpu
alias cpuinfo='lscpu'
# Get server cpu info
alias gpumeminfo='grep -i --color memory /var/log/Xorg.0.log'
# get GPU ram on desktop / laptop
alias free='free -h'
