dotfiles/shell/aliases.sh

125 lines
4.3 KiB
Bash
Raw Normal View History

2017-01-26 13:48:55 +01:00
#!/bin/sh
2017-01-26 13:48:55 +01:00
#alias definitions
alias cd..="cd .."
alias gits="git status"
alias les="less"
alias quit="exit"
alias :q="exit"
alias :qa="exit"
alias :q!="exit"
alias :qw="exit"
alias vim="vim -p"
alias vi="vim -p"
alias yt-dlp='yt-dlp -o "%(title)s.%(ext)s"'
alias yt-audio='yt-dlp -o "%(title)s.%(ext)s" --extract-audio'
alias yt-mp3='yt-dlp -o "%(title)s.%(ext)s" --extract-audio --audio-format mp3'
2017-02-14 22:04:35 +01:00
alias music-gain="find ~/Music -iname '*.mp3' -execdir mp3gain -q -k -p {} \+"
2022-02-28 17:52:20 +01:00
alias music-fix="find ~/Music -print0 | xargs -P 0 -0 nice -n 19 mp3val -f -si"
2017-01-26 13:48:55 +01:00
alias grep="grep --color=auto"
alias ls='ls --color=auto'
alias fuck="sudo !!"
alias fu='sudo "$BASH" -c "$(history -p !!)"'
# open any file wihtout the knowledge of what type it is
alias of="xdg-open"
# only list the IO of <processname> with iotop
# io <processname>
io(){
local sudo_needed
2021-12-06 12:41:02 +01:00
[ -n "$(type sudo 2>/dev/null)" ] && [ "$USER" != 'root' ] \
&& sudo_needed="sudo"
2021-12-06 12:41:02 +01:00
${sudo_needed} iotop -p"$(pidof "$1" | sed 's/ / -p/g')"
}
2021-12-06 12:41:02 +01:00
if [ -n "$(type sudo 2>/dev/null)" ] && [ "$USER" != 'root' ]; then
2017-01-26 13:48:55 +01:00
#create sudo aliases WITHOUT leading s
for sudo in fwupdmgr mount umount iftop iotop fsadm lvchange lvconvert lvcreate lvdisplay lvextend lvm lvmchange lvmconf lvmconfig lvmdiskscan lvmdump lvmetad lvmsadc lvmsar lvreduce lvremove lvrename lvresize lvs lvscan pvchange pvck pvcreate pvdisplay pvmove pvremove pvresize pvs pvscan vgcfgbackup vgcfgrestore vgchange vgck vgconvert vgcreate vgdisplay vgexport vgextend vgimport vgimportclone vgmerge vgmknodes vgreduce vgremove vgrename vgs vgscan vgsplit;
2017-01-26 13:48:55 +01:00
do
type $sudo > /dev/null 2>&1 && alias $sudo="sudo $sudo";
done
unset sudo
#create sudo aliases WITH leading s
for sudo in ps vim chown chmod;
do
type $sudo > /dev/null 2>&1 && alias s$sudo="sudo $sudo";
done
unset sudo
type pacman >/dev/null 2>&1 && pacman(){
local sudo_needed
# Check if pacman has -S, -R or -U option
# which should indicate in most times if we need sudo
2017-02-14 12:15:53 +01:00
echo "$*" | grep -- "-[SRU]" >/dev/null 2>&1 \
&& sudo_needed="sudo"
2021-12-06 12:41:02 +01:00
${sudo_needed} /usr/bin/pacman "$@"
}
2017-01-26 13:48:55 +01:00
fi
2017-09-22 13:29:19 +02:00
alias pwedit="sudo vim -p /etc/{passwd,group,shadow,gshadow}"
alias cmdlist='find $(echo $PATH | tr ":" "\n") | awk -F / "{print \$NF}" | sort -u'
2017-01-26 13:48:55 +01:00
alias makepasswd='makepasswd --minchars=10 --maxchars=25 --count=10'
alias ssh-keygen-secure="ssh-keygen -o -a 64 -t ed25519"
alias shuttle='sshuttle --dns -r uberspace 0/0'
2019-06-08 12:45:31 +02:00
alias mosh-uberspace="mosh uberspace -p 40201"
2023-07-09 20:45:23 +02:00
alias sync-progress="watch -d grep -e Dirty: -e Writeback: /proc/meminfo"
2017-01-26 13:48:55 +01:00
alias vnc-temp='x11vnc -display :0 -nap -wait 50 -noxdamage -forever -rfbauth ~/.vnc/passwd -speeds 50,1,1'
2017-01-26 13:48:55 +01:00
alias notify='notify-send Terminal "Process has been finished"'
# xorg
alias screen-off-x='xset -display :0.0 dpms force off'
alias screen-update-x="xrandr --auto"
# wayland:
alias pdfpc="pdfpc --wayland-workaround"
alias screen-off-wl="swayidle timeout 1 'swaymsg \"output * dpms off\"' resume 'swaymsg \"output * dpms on\"; pkill -n swayidle'"
alias use-x11="QT_QPA_PLATFORM=xcb"
2017-01-26 13:48:55 +01:00
# DEBIAN:
alias sag='sudo apt-get'
alias key-renew='apt-key adv --keyserver keyserver.ubuntu.com --recv-keys'
alias key-repair-all='wget -q http://archive.getdeb.net/getdeb-archive.key -O- | sudo apt-key add - '
# ARCH:
alias pacman-update='sudo pacman -Syu'
alias aur-update='yay -Syua'
2017-01-26 13:48:55 +01:00
2021-05-03 23:54:27 +02:00
# NIX:
2022-11-29 20:33:28 +01:00
alias nix-list-results='ls -l /nix/var/nix/gcroots/auto/'
alias nixpkgs-build='nix-build . -A'
2023-10-28 19:44:57 +02:00
alias nixpkgs-review-fast-merge='nixpkgs-review post-result && nixpkgs-review approve && nixpkgs-review merge'
2021-05-03 23:54:27 +02:00
# DOTFILES:
alias dotfile-update-submodules='cd ~/.dotfiles/ && git submodule foreach git pull origin master'
# ESP32:
alias esp32-flash="esptool --chip esp32 -p /dev/ttyUSB? write_flash -z 0x1000"
alias esp32-mount="mpy-fuse --port /dev/ttyUSB? --baud 115200"
alias esp32-terminal="screen /dev/ttyUSB? 115200"
2017-01-26 13:48:55 +01:00
# TEE:
alias ttime_green="sh -c \"sleep 180 && notify-send -u critical 'The tea is ready'\" &"
alias ttime_black="sh -c \"sleep 300 && notify-send -u critical 'The tea is ready'\" &"
2021-12-06 12:41:02 +01:00
# IPv6 ping
for INTERFACE in /sys/class/net/*; do
[ -e "$INTERFACE" ] || break # incase it is empty
INTERFACE=$(basename "$INTERFACE")
alias ping-all-$INTERFACE="ping -6 ff02::1%$INTERFACE"
alias ping-routes-$INTERFACE="ping -6 ff02::2%$INTERFACE"
done
2018-06-18 18:30:53 +02:00
alias sort-by-size="du -hsc * | sort -hk1"
2017-01-26 13:48:55 +01:00
#END alias-definitions