dotfiles/bash/.alias.sh

163 lines
5.2 KiB
Bash
Raw Normal View History

2017-12-06 18:30:31 +01:00
# useful dockers
alias phpserver='docker run --rm -p 2000:80 -v "$PWD":/var/www/html mastermindzh/php-xdebug'
alias nodeserver='docker run --rm -p 3000:3000 -v "$PWD":/app mastermindzh/generic_node'
alias reactserver='docker run --rm -p 8080:8080 -v "$PWD":/app mastermindzh/generic_node'
2018-12-27 08:27:03 +01:00
alias mongoserver='docker run -d --rm -p 27017:27017 --name mongo-server -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=123 -v ~/.db/mongo:/data/db mongo'
alias sqlserver='docker run -d --rm --name sql-server -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Your_Password123" -p 1433:1433 -v ~/.db/mssql:/var/opt/mssql microsoft/mssql-server-linux'
2017-12-06 18:30:31 +01:00
2018-02-13 20:45:44 +01:00
# useful docker commands
alias stop-dockers='docker stop $(docker ps -aq)'
alias docker-clean-containers='docker container prune -f --filter "until=48h"'
alias docker-clean-images='docker image prune -a -f --filter "until=48h"'
alias docker-clean-volumes='docker volume prune -f --filter "label!=keep"'
alias docker-clean-networks='docker network prune -f --filter "until=24h"'
alias docker-clean-all='docker system prune -f --volumes'
2018-02-13 20:45:44 +01:00
2017-12-06 18:30:31 +01:00
#upload text to sprunge.us
#USAGE cat file.txt | sprunge
alias sprunge='curl -F "sprunge=<-" http://sprunge.us'
## pacman and trizen
alias aur='trizen --noconfirm'
alias update='trizen -Syyu --noconfirm'
2018-11-27 13:46:44 +01:00
alias updatekeys='sudo pacman-key --refresh-key'
2019-06-19 08:26:06 +02:00
alias cleanpacmancache='sudo paccache -rk 1 && sudo paccache -ruk0'
2017-12-06 18:30:31 +01:00
## systeminfo
alias meminfo='free -mth'
alias cpuinfo='lscpu'
alias hddinfo='df -h'
alias temp='watch "sensors | grep Core"'
alias internalip=$'ip route get 8.8.8.8 | awk \'NR==1 {print $NF}\''
2018-11-27 13:46:44 +01:00
alias preferredapps='exo-preferred-applications'
2017-12-06 18:30:31 +01:00
#show 5 most memory consuming apps
alias psmem='ps auxf | sort -nr -k 5 | head -n 5'
#dotnet core
alias efupdate="dotnet ef database update"
alias efmigrate="dotnet ef migrations add"
alias efremove="dotnet ef migrations remove"
2018-08-13 10:38:18 +02:00
alias dotnetnew="dotnet new webapi -o "
2017-12-06 18:30:31 +01:00
##utility
alias nmapscan='nmap -n -sP'
2018-06-09 13:57:20 +02:00
alias pia='nohup sh /opt/pia/run.sh &>/dev/null & disown'
alias wifimenu='nm-connection-editor'
2019-03-22 10:02:55 +01:00
alias findcrlf='find . -path node_modules -prune -o -not -type d -exec file "{}" ";" | grep -E "BOM|CRLF"'
alias fixcrlf='findcrlf > /tmp/crlftolf && cat /tmp/crlftolf | while read line; do CUTLINE=$(echo $line | cut -f1 -d":") && dos2unix $CUTLINE; done'
2019-02-20 08:51:56 +01:00
alias mountrick='sudo mount -t cifs //192.168.1.2/Rick /mnt/rick/ -o username=mastermindzh,noexec'
2019-05-21 18:31:37 +02:00
alias enable-wifi='sudo ip link set wlp2s0 up'
alias scan-wifi='sudo iw dev wlp2s0 scan'
alias pretty-json='python -m json.tool'
alias addpgpkey='gpg --recv-keys'
2017-12-06 18:30:31 +01:00
# cli tools
alias crypto='curl -s rate.sx?qF | head -n -2 | tail -n +10'
2017-12-06 18:30:31 +01:00
# show file content without comment lines
alias nocomment='grep -Ev '\''^(#|$)'\'''
# list files/dirs on separate lines
alias list='find ./ -maxdepth 1 -printf "%f\n"'
2017-12-06 18:30:31 +01:00
#show directories
alias dirs='ls -FlA | grep :*/'
#show executables
alias execx='ls -FlA | grep -v \*'
#ls -al
alias la='ls -al'
# show external ip
alias cmyip='curl -s http://ipecho.net/plain; echo'
## default command fixes :P
alias mkdir='mkdir -p'
alias wget='wget -c'
2019-07-04 22:33:48 +02:00
alias ls='ls -l --color=auto'
alias installed='sudo pacman -Qetq'
alias aurinstalled='sudo pacman -Qmq'
2018-05-07 22:56:26 +02:00
alias sudo='sudo '
2018-11-27 13:46:44 +01:00
alias markdown-toc='markdown-toc --bullets="-" -i'
2019-03-22 10:02:55 +01:00
alias tree='tree --dirsfirst'
alias handbrake='ghb'
2018-05-07 22:56:26 +02:00
# grub
alias update-grub='grub-mkconfig -o /boot/grub/grub.cfg'
2017-12-06 18:30:31 +01:00
2018-08-29 09:10:08 +02:00
# git
alias gitremovelocalbranches='git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d'
2018-10-22 10:49:21 +02:00
alias untangle-line-endings='find ./ -type f -exec dos2unix {} \;'
# development
alias chromecors='google-chrome-stable --disable-web-security --user-data-dir="~/.chrome-unsafe"'
2018-10-22 10:49:21 +02:00
2018-08-29 09:10:08 +02:00
2017-12-06 18:30:31 +01:00
## Functions
# function to cd up a couple of times
# USAGE: up 3 (goes up 3 directories)
up(){
DEEP=$1;
[ -z "${DEEP}" ] && { DEEP=1; };
for i in $(seq 1 ${DEEP}); do
cd ../;
done;
2017-12-06 18:30:31 +01:00
}
# function to extract ... well anything really
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "don't know how to extract '$1'..." ;;
esac
else
echo "'$1' is not a valid file!"
fi
2017-12-06 18:30:31 +01:00
}
# function to return uptime in a human readable format
myuptime () {
uptime | awk '{ print "Uptime:", $3, $4, $5 }' | sed 's/,//g'
return;
2017-12-06 18:30:31 +01:00
}
# function to check whether a specific host is up
isup(){
if ! [ -z "$1" ]; then
ping -c 3 $1 > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "$1 Seems to be offline";
else
echo "$1 Seems to be online";
fi
fi
2017-12-06 18:30:31 +01:00
}
# function to print a line across the screen
printLine(){
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
2017-12-06 18:30:31 +01:00
}
# function to kill a port
killport () {
if [ -z "$1" ] ; then
echo "please specify a port to kill"
else
fuser -k $1/tcp
fi
}