dotfiles/bash/.alias.sh

203 lines
6.3 KiB
Bash
Raw Normal View History

2023-12-10 00:02:08 +01:00
#!/bin/bash
# source program-specific aliases:
for f in ~/.aliases/*; do source "$f"; done
#dotnet core
alias efupdate="dotnet ef database update"
alias efmigrate="dotnet ef migrations add"
alias efremove="dotnet ef migrations remove"
alias dotnetnew="dotnet new webapi -o "
alias nuget-force-clear-cache="nuget locals all -clear && nuget locals all -list | awk '{split($0,a,\": \"); print a[2];}' | xargs rm -rf"
# git
alias gitremovelocalbranches='git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d'
alias untangle-line-endings='find ./ -type f -exec dos2unix {} \;'
2019-12-03 08:53:23 +01:00
alias undo-commit='git reset --soft HEAD^'
2017-12-06 18:30:31 +01:00
## pacman and trizen
alias aur='trizen --noconfirm'
2022-11-05 20:27:14 +01:00
alias update='trizen --sudo_remove_timestamp=0 --sudo_autorepeat=1 --sudo_autorepeat_at_runtime=1 -Syu --noconfirm'
alias remove-orphans='sudo pacman -Rns $(pacman -Qtdq)'
2018-11-27 13:46:44 +01:00
alias updatekeys='sudo pacman-key --refresh-key'
alias updatemirrors='sudo reflector --latest 20 --protocol http,https --sort rate --save /etc/pacman.d/mirrorlist'
2019-07-25 14:53:30 +02:00
alias clean-pacmancache='sudo paccache -rk 1 && sudo paccache -ruk0'
alias clean-trizen-cache='sudo trizen -Scc'
2023-12-10 00:02:08 +01:00
alias clean-trash='sudo rm -rf ~/.local/share/Trash/*'
alias clean-journal='sudo journalctl --vacuum-time=2d'
alias clean-pacman-unused='sudo pacman -R $(pacman -Qtdq)'
alias clean-all='clean-pacman-unused && clean-pacmancache && clean-trizen-cache && docker-clean-all && clean-node_modules && clean-journal && clean-trash'
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'
# utility
2017-12-06 18:30:31 +01:00
alias nmapscan='nmap -n -sP'
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-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'
alias dotnet-install='~/.dotnet-install.sh --install-dir /usr/share/dotnet/ -channel Current -version '
alias mountshares='sudo bash ~/dotfiles/bash/mounts.sh'
2021-10-19 11:05:34 +02:00
alias echo-server='npx http-echo-server'
alias mountcalibre='sudo mount.cifs //10.10.1.11/books /mnt/calibre -o nobrl,user=mastermindzh,noperm,rw'
alias xpid="xprop _NET_WM_PID | cut -d' ' -f3"
2023-12-10 00:02:08 +01:00
alias clean-obj-bin='sudo find . -name "bin" -o -name "obj" -exec rm -rf {} \;'
alias nomachine='/usr/NX/bin/nxplayer'
alias unlockuser='faillock --reset --user'
alias npm-list-links='npm ls -g --depth=0 --link=true'
2022-05-23 10:15:52 +02:00
alias suspend='sudo bash ~/.config/i3/scripts/suspend.sh'
alias clean-all='sudo pacman -R $(pacman -Qtdq) && sudo paccache -rk 1 && sudo paccache -ruk0 && sudo journalctl --vacuum-time=2d && docker-clean-all && rm -rf ~/.local/share/Trash/'
2022-11-05 20:27:14 +01:00
alias delete-empty='find . -type d -empty -delete'
2022-12-28 22:48:06 +01:00
alias addwireguard='sudo nmcli connection import type wireguard file '
alias defaultfonts='for family in serif sans-serif monospace Arial Helvetica Verdana "Times New Roman" "Courier New"; do echo -e "\033[1m$family: \033[0m" && fc-match "$family" && echo ""; done'
2022-12-28 22:48:06 +01:00
# might be useful in demos...
alias oopsie='fuck'
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
2022-05-16 17:00:57 +02:00
alias dirs='ls -FlA | grep :*/'
2017-12-06 18:30:31 +01:00
#show executables
2022-05-16 17:00:57 +02:00
alias execx='ls -FlA | grep -v \*'
2017-12-06 18:30:31 +01:00
#ls -al
alias la='ls -al'
# show external ip
alias cmyip='curl -s http://ipecho.net/plain; echo'
# File merging
alias pngtopdf="convert *.png"
alias jpgtopdf="convert *.jpg"
2017-12-06 18:30:31 +01:00
## default command fixes :P
alias mkdir='mkdir -p'
alias wget='wget -c'
2021-02-03 17:09:38 +01:00
alias ls='ls -lh --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'
alias cal='cal -mw --color'
alias chrome='google-chrome-stable'
2022-08-16 12:42:50 +02:00
alias teams='teams-insiders --disable-seccomp-filter-sandbox'
alias cat='bat'
alias grep='grep -i'
2018-05-07 22:56:26 +02:00
## command overrides
df() {
duf
}
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
## Functions
# function to cd up a couple of times
# USAGE: up 3 (goes up 3 directories)
2022-05-16 17:00:57 +02:00
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
2022-05-16 17:00:57 +02:00
extract() {
2023-12-10 00:02:08 +01:00
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" ;;
2022-05-16 17:00:57 +02:00
*) 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
2022-05-16 17:00:57 +02:00
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
2022-05-16 17:00:57 +02:00
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
2022-05-16 17:00:57 +02:00
printLine() {
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
2017-12-06 18:30:31 +01:00
}
# function to kill a port
2022-05-16 17:00:57 +02:00
killport() {
if [ -z "$1" ]; then
echo "please specify a port to kill"
else
2023-12-10 00:02:08 +01:00
fuser -k "$1/tcp"
2022-05-16 17:00:57 +02:00
fi
}
2023-12-10 00:02:08 +01:00
# merges all pdfs in current directory into a new pdf
mergepdf() {
2022-05-16 17:00:57 +02:00
if [ -z "$1" ]; then
2023-12-10 00:02:08 +01:00
echo "please provide an output name for your pdf file: mergepdf out.pdf"
2022-05-16 17:00:57 +02:00
else
2023-12-10 00:02:08 +01:00
pdfunite ./*.pdf "$1"
2022-05-16 17:00:57 +02:00
fi
}
2023-12-10 00:02:08 +01:00
# sign a file using the signing key
signfile() {
2022-05-16 17:00:57 +02:00
if [ -z "$1" ]; then
2023-12-10 00:02:08 +01:00
echo "please provide a file to sign: signfile file-to-sign.pdf"
2022-05-16 17:00:57 +02:00
else
2023-12-10 00:02:08 +01:00
ssh-keygen -Y sign -f ~/.ssh/signing-key.pub -n file "$1"
2022-05-16 17:00:57 +02:00
fi
}
2023-12-10 00:02:08 +01:00
alias "set-timezone-romania"='timedatectl set-timezone Europe/Bucharest'
alias "set-timezone-netherlands"=' timedatectl set-timezone Europe/Amsterdam'