2019-10-26 17:05:31 +00:00
|
|
|
|
# git shorthands
|
2020-01-13 09:03:59 +00:00
|
|
|
|
alias gc='git commit'
|
|
|
|
|
alias gac='ga && gc'
|
|
|
|
|
alias gpull='git pull'
|
|
|
|
|
alias gpush='git push'
|
2019-10-26 17:05:31 +00:00
|
|
|
|
|
2020-11-25 08:06:19 +00:00
|
|
|
|
alias mutt='neomutt'
|
2020-07-11 11:15:50 +00:00
|
|
|
|
|
2021-08-17 17:32:46 +00:00
|
|
|
|
# make skim zsh plugin use fd
|
|
|
|
|
_skim_compgen_dir() {
|
2021-08-03 09:03:39 +00:00
|
|
|
|
fd -Ht d
|
2020-01-09 20:30:32 +00:00
|
|
|
|
}
|
2021-08-17 17:32:46 +00:00
|
|
|
|
_skim_compgen_path() {
|
2021-08-03 09:03:39 +00:00
|
|
|
|
fd -Ht f
|
2020-01-09 20:30:32 +00:00
|
|
|
|
}
|
2021-08-17 17:32:46 +00:00
|
|
|
|
# same for fzf
|
|
|
|
|
_fzf_compgen_dir() {
|
|
|
|
|
_skim_compgen_dir
|
|
|
|
|
}
|
|
|
|
|
_fzf_compgen_path() {
|
|
|
|
|
_skim_compgen_path
|
|
|
|
|
}
|
2020-01-09 20:30:32 +00:00
|
|
|
|
|
2021-08-18 06:30:21 +00:00
|
|
|
|
# Modern replacements for cat and ls
|
2021-08-18 06:31:32 +00:00
|
|
|
|
alias cat='bat --paging=never'
|
2021-08-18 06:30:21 +00:00
|
|
|
|
alias ls='exa'
|
|
|
|
|
|
2021-08-17 18:02:58 +00:00
|
|
|
|
{%@@ if profile != "mko-laptop" @@%}
|
2021-08-17 17:54:45 +00:00
|
|
|
|
# Command not found handler
|
|
|
|
|
# source https://wiki.archlinux.org/title/Zsh#pacman_-F_%22command_not_found%22_handler
|
|
|
|
|
function command_not_found_handler {
|
|
|
|
|
local purple='\e[1;35m' bright='\e[0;1m' green='\e[1;32m' reset='\e[0m'
|
|
|
|
|
printf 'zsh: command not found: %s\n' "$1"
|
|
|
|
|
local entries=(
|
|
|
|
|
${(f)"$(/usr/bin/pacman -F --machinereadable -- "/usr/bin/$1")"}
|
|
|
|
|
)
|
|
|
|
|
if (( ${#entries[@]} ))
|
|
|
|
|
then
|
|
|
|
|
printf "${bright}$1${reset} may be found in the following packages:\n"
|
|
|
|
|
local pkg
|
|
|
|
|
for entry in "${entries[@]}"
|
|
|
|
|
do
|
|
|
|
|
# (repo package version file)
|
|
|
|
|
local fields=(
|
|
|
|
|
${(0)entry}
|
|
|
|
|
)
|
|
|
|
|
if [[ "$pkg" != "${fields[2]}" ]]
|
|
|
|
|
then
|
|
|
|
|
printf "${purple}%s/${bright}%s ${green}%s${reset}\n" "${fields[1]}" "${fields[2]}" "${fields[3]}"
|
|
|
|
|
fi
|
|
|
|
|
printf ' /%s\n' "${fields[4]}"
|
|
|
|
|
pkg="${fields[2]}"
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
}
|
2021-08-17 18:02:58 +00:00
|
|
|
|
{%@@ endif @@%}
|
2021-08-17 17:54:45 +00:00
|
|
|
|
|
2021-08-17 16:17:38 +00:00
|
|
|
|
# search and install packages with skim
|
2020-11-19 22:23:02 +00:00
|
|
|
|
pi() {
|
2021-08-17 16:17:38 +00:00
|
|
|
|
SELECTED_PKGS="$(paru -Slq | sk --header='Install packages' -m --preview 'paru -Si {1}')"
|
2019-10-26 17:05:31 +00:00
|
|
|
|
if [ -n "$SELECTED_PKGS" ]; then
|
2021-08-17 16:17:38 +00:00
|
|
|
|
# Append the expanded command to history
|
|
|
|
|
print -s "paru -S $(echo $SELECTED_PKGS)"
|
2020-11-19 22:23:02 +00:00
|
|
|
|
paru -S $(echo $SELECTED_PKGS)
|
2019-10-26 17:05:31 +00:00
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-17 16:17:38 +00:00
|
|
|
|
# search and remove packages with skim
|
2020-11-19 22:23:02 +00:00
|
|
|
|
pr() {
|
2021-08-17 16:17:38 +00:00
|
|
|
|
SELECTED_PKGS="$(paru -Qsq | sk --header='Remove packages' -m --preview 'paru -Si {1}')"
|
2019-10-26 17:05:31 +00:00
|
|
|
|
if [ -n "$SELECTED_PKGS" ]; then
|
2021-08-17 16:17:38 +00:00
|
|
|
|
# Append the expanded command to history
|
|
|
|
|
print -s "paru -Rns $(echo $SELECTED_PKGS)"
|
2020-11-19 22:23:02 +00:00
|
|
|
|
paru -Rns $(echo $SELECTED_PKGS)
|
2019-10-26 17:05:31 +00:00
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-17 17:32:46 +00:00
|
|
|
|
# find and open man pages with skim
|
2019-10-26 17:05:31 +00:00
|
|
|
|
fman() {
|
2021-08-17 17:32:46 +00:00
|
|
|
|
man -k . | sk --prompt='Man> ' | awk '{print $1}' | xargs -r man
|
2019-10-26 17:05:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# I'm retarded so I need this
|
2020-01-13 09:03:59 +00:00
|
|
|
|
alias :q='exit'
|
|
|
|
|
alias :wq='exit'
|
2019-10-26 17:05:31 +00:00
|
|
|
|
|
2020-03-30 15:21:00 +00:00
|
|
|
|
alias reboot-kodi='systemctl reboot --boot-loader-entry=kodi.conf'
|
|
|
|
|
|
2019-10-26 17:05:31 +00:00
|
|
|
|
# zbar output only data
|
2020-01-13 09:03:59 +00:00
|
|
|
|
alias zbarimg='zbarimg -q --raw'
|
|
|
|
|
alias zbarcam='zbarcam -q --raw'
|
2020-01-12 13:37:15 +00:00
|
|
|
|
|
2020-04-18 10:41:00 +00:00
|
|
|
|
# shorten systemctl and journalctl
|
|
|
|
|
alias sc='systemctl'
|
2020-01-13 09:03:59 +00:00
|
|
|
|
alias scu='systemctl --user'
|
2020-04-18 10:41:00 +00:00
|
|
|
|
alias jc='journalctl'
|
|
|
|
|
alias jcu='journalctl --user'
|
2019-10-26 17:05:31 +00:00
|
|
|
|
|
|
|
|
|
# switch to desktop mode
|
2020-01-13 09:03:59 +00:00
|
|
|
|
alias dock='swaymsg output eDP-1 disable'
|
2019-10-26 17:05:31 +00:00
|
|
|
|
|
|
|
|
|
# move to trash instead of remove
|
2020-01-13 09:03:59 +00:00
|
|
|
|
alias rm='trash'
|
2019-10-26 17:05:31 +00:00
|
|
|
|
|
|
|
|
|
# clean stuff
|
|
|
|
|
clean() {
|
|
|
|
|
DFCMD="df -h / | tail -n 1 | cut -d' ' -f8- | cut -d' ' -f1 | sed 's/[^0-9]*//g'"
|
|
|
|
|
SPACEBEFORE=$(eval "$DFCMD")
|
|
|
|
|
trash-empty 10
|
|
|
|
|
sudo journalctl --vacuum-size=500M
|
2020-11-19 22:23:02 +00:00
|
|
|
|
paru -Sc
|
2019-10-26 17:05:31 +00:00
|
|
|
|
SPACEAFTER=$(eval "$DFCMD")
|
|
|
|
|
echo "Saved $(calc $SPACEAFTER - $SPACEBEFORE)G of space"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# connect to wireguard
|
2020-01-13 09:03:59 +00:00
|
|
|
|
alias startvpn='sudo systemctl start wg-quick@wg0.service'
|
|
|
|
|
alias stopvpn='sudo systemctl stop wg-quick@wg0.service'
|
2019-10-26 17:05:31 +00:00
|
|
|
|
|
|
|
|
|
# connect to metropolia vpn
|
2020-01-13 09:03:59 +00:00
|
|
|
|
alias metropoliavpn='sudo openconnect -u markoak --passwd-on-stdin vpn.metropolia.fi'
|
2019-10-26 17:05:31 +00:00
|
|
|
|
|
|
|
|
|
# read qrcode from selection
|
|
|
|
|
qr() { grim -g "$(slurp -d)" - | zbarimg PNG:- }
|
|
|
|
|
|
|
|
|
|
# generate qr code in terminal
|
2020-01-13 09:03:59 +00:00
|
|
|
|
alias qrencode='qrencode -t ansiutf8'
|
2019-10-26 17:05:31 +00:00
|
|
|
|
|
|
|
|
|
# color picker
|
|
|
|
|
cpick() { grim -g "$(slurp -p)" -t ppm - | convert - -format "%[pixel:p{0,0}]" txt:- }
|
|
|
|
|
|
|
|
|
|
#iwctl aliases
|
2020-01-13 09:03:59 +00:00
|
|
|
|
alias i='iwctl station wlan0'
|
2019-10-26 17:05:31 +00:00
|
|
|
|
|
|
|
|
|
# change cpu power settings
|
2020-04-13 10:24:20 +00:00
|
|
|
|
gpulow() {
|
2020-01-14 13:11:11 +00:00
|
|
|
|
echo low | sudo tee /sys/class/drm/card0/device/power_dpm_force_performance_level
|
|
|
|
|
}
|
2020-04-13 10:24:20 +00:00
|
|
|
|
gpuauto() {
|
2020-01-14 13:11:11 +00:00
|
|
|
|
echo auto | sudo tee /sys/class/drm/card0/device/power_dpm_force_performance_level
|
|
|
|
|
}
|
2019-10-26 17:05:31 +00:00
|
|
|
|
|
|
|
|
|
# monitor cpu freq
|
2020-01-13 09:03:59 +00:00
|
|
|
|
cpufreq() { watch -n 1 eval "cat /proc/cpuinfo | grep MHz" }
|
2019-10-26 17:05:31 +00:00
|
|
|
|
|
|
|
|
|
# dotdrop
|
2019-11-02 06:56:41 +00:00
|
|
|
|
updatesecrets() { bash $DOTREPO/secrets/secrets.sh; chmod 600 $DOTREPO/secrets/secrets }
|
2020-11-21 15:41:44 +00:00
|
|
|
|
dotdrop() { source $DOTREPO/secrets/secrets && $DOTREPO/dotdrop.sh $@ }
|
2020-11-21 13:37:58 +00:00
|
|
|
|
sdotdrop() { source $DOTREPO/secrets/secrets && sudo -E $DOTREPO/dotdrop.sh --cfg=$DOTREPO/config-root.yaml $@ }
|
2020-01-13 09:03:59 +00:00
|
|
|
|
compdef _dotdrop-completion.zsh sdotdrop
|
|
|
|
|
alias dotgit='git -C $DOTREPO'
|
2019-10-26 17:05:31 +00:00
|
|
|
|
dotsync() { cd $DOTREPO && gpull && ga && gc && gpush && cd $OLDPWD }
|
|
|
|
|
|
2020-04-14 11:03:21 +00:00
|
|
|
|
|
2019-10-26 17:05:31 +00:00
|
|
|
|
# sync password manager
|
|
|
|
|
passync() { pass git pull && pass git push && updatesecrets }
|
|
|
|
|
|
2020-04-14 11:38:51 +00:00
|
|
|
|
update() {
|
|
|
|
|
all() {
|
2020-12-25 09:11:53 +00:00
|
|
|
|
paru
|
2020-04-14 11:38:51 +00:00
|
|
|
|
plugins
|
|
|
|
|
{%@@ if profile == "Moria" @@%}
|
2020-12-25 08:59:03 +00:00
|
|
|
|
repo
|
2020-04-15 10:09:11 +00:00
|
|
|
|
docker-update
|
2020-05-31 10:12:44 +00:00
|
|
|
|
docker system prune --volumes
|
2020-04-14 11:38:51 +00:00
|
|
|
|
{%@@ endif @@%}
|
2020-12-25 09:11:53 +00:00
|
|
|
|
sudo flatpak update
|
2020-04-14 11:38:51 +00:00
|
|
|
|
sudo awman-update
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 08:59:03 +00:00
|
|
|
|
repo() {
|
2021-01-16 10:07:38 +00:00
|
|
|
|
aur sync -Su --margs --noconfirm
|
2021-01-19 16:40:44 +00:00
|
|
|
|
firefox
|
2021-01-16 10:07:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
firefox() {
|
2021-01-16 10:10:24 +00:00
|
|
|
|
aur sync -S --rebuild firefox-nightly --margs --noconfirm
|
2020-04-14 11:38:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
plugins() {
|
2021-08-22 08:36:58 +00:00
|
|
|
|
nvim +PackerSync +TSUpdate
|
2020-04-14 11:38:51 +00:00
|
|
|
|
zinit self-update
|
|
|
|
|
zinit update -p
|
|
|
|
|
$HOME/.tmux/plugins/tpm/bin/update_plugins all
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-15 10:09:11 +00:00
|
|
|
|
docker-update() {
|
2020-11-21 13:37:58 +00:00
|
|
|
|
for dir in $HOME/git/dotfiles/docker/*; do
|
2020-04-14 11:38:51 +00:00
|
|
|
|
cd $dir
|
2021-09-29 15:19:54 +00:00
|
|
|
|
docker compose pull
|
2021-09-29 15:04:08 +00:00
|
|
|
|
docker compose up -d
|
2020-04-14 11:38:51 +00:00
|
|
|
|
cd ..
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
|
1=base
|
|
|
|
|
fi
|
2020-04-14 11:03:21 +00:00
|
|
|
|
|
2020-04-14 11:38:51 +00:00
|
|
|
|
case "$1" in
|
|
|
|
|
all)
|
|
|
|
|
all
|
|
|
|
|
;;
|
|
|
|
|
plugins)
|
|
|
|
|
plugins
|
|
|
|
|
;;
|
|
|
|
|
docker)
|
2020-04-15 10:09:11 +00:00
|
|
|
|
docker-update
|
2020-04-14 11:38:51 +00:00
|
|
|
|
;;
|
2020-12-25 09:11:53 +00:00
|
|
|
|
repo)
|
|
|
|
|
repo
|
|
|
|
|
;;
|
2021-01-16 10:13:33 +00:00
|
|
|
|
firefox)
|
|
|
|
|
firefox
|
|
|
|
|
;;
|
2020-04-14 11:38:51 +00:00
|
|
|
|
*)
|
2020-12-25 08:59:03 +00:00
|
|
|
|
paru
|
2020-04-14 11:38:51 +00:00
|
|
|
|
;;
|
|
|
|
|
esac
|
2020-04-14 11:03:21 +00:00
|
|
|
|
}
|
2019-10-26 17:05:31 +00:00
|
|
|
|
|
|
|
|
|
# remove unneeded packages
|
2020-03-24 08:43:19 +00:00
|
|
|
|
autoremove() { sudo pacman -Rns $(pacman -Qdtq) }
|
2019-10-26 17:05:31 +00:00
|
|
|
|
|
|
|
|
|
# turn on usb tethering on my android phone
|
|
|
|
|
tether() { adb shell su -c "service call connectivity 33 i32 1 s16 me" > /dev/null }
|
|
|
|
|
|
|
|
|
|
# update arch mirrorlist
|
2020-01-13 09:03:59 +00:00
|
|
|
|
alias reflect='sudo reflector --latest 200 --threads 8 --verbose --protocol http --protocol https --sort rate --save /etc/pacman.d/mirrorlist'
|
2019-10-26 17:05:31 +00:00
|
|
|
|
|
|
|
|
|
# default icon for notify-send
|
2020-01-13 09:03:59 +00:00
|
|
|
|
alias notify-send='notify-send --icon=alarm'
|
2019-10-29 22:43:03 +00:00
|
|
|
|
|
2020-03-03 14:54:32 +00:00
|
|
|
|
# download archiso
|
|
|
|
|
alias archiso='curl "http://mirror.rackspace.com/archlinux/iso/$(date +%Y.%m).01/archlinux-$(date +%Y.%m).01-x86_64.iso"'
|
|
|
|
|
|
2020-12-20 13:34:07 +00:00
|
|
|
|
# Update repository
|
|
|
|
|
|
2019-12-12 12:50:06 +00:00
|
|
|
|
|
|
|
|
|
# encrypted tar's with zstd compression
|
|
|
|
|
cgpgtar() { tar cf - --zstd $1 | gpg -e -z 0 > $1.tar.zst.gpg }
|
|
|
|
|
xgpgtar() { gpg -d $1 | tar x --zstd }
|
2019-11-11 06:32:25 +00:00
|
|
|
|
|
2019-10-29 22:43:03 +00:00
|
|
|
|
# colorise output
|
2021-06-11 07:55:55 +00:00
|
|
|
|
alias cvs='grc cvs'
|
|
|
|
|
alias df='grc df'
|
|
|
|
|
alias digg='grc digg'
|
|
|
|
|
alias gcc='grc gcc'
|
|
|
|
|
alias g++='grc g++'
|
|
|
|
|
alias ifconfig='grc ifconfig'
|
|
|
|
|
alias make='grc make'
|
|
|
|
|
alias mount='grc mount'
|
|
|
|
|
alias mtr='grc mtr'
|
|
|
|
|
alias netstat='grc mount'
|
|
|
|
|
alias ping='grc ping'
|
|
|
|
|
alias ps='grc ps'
|
|
|
|
|
alias tail='grc tail'
|
|
|
|
|
alias traceroute='grc traceroute'
|
|
|
|
|
alias wdiff='grc wdiff'
|
|
|
|
|
alias blkid='grc blkid'
|
|
|
|
|
alias du='grc du'
|
|
|
|
|
alias dnf='grc dnf'
|
|
|
|
|
alias docker='grc docker'
|
|
|
|
|
alias docker-machine='grc docker-machine'
|
|
|
|
|
alias env='grc env'
|
|
|
|
|
alias id='grc id'
|
|
|
|
|
alias ip='grc ip'
|
|
|
|
|
alias iostat='grc iostat'
|
|
|
|
|
alias last='grc last'
|
|
|
|
|
alias lsattr='grc lsattr'
|
|
|
|
|
alias lsblk='grc lsblk'
|
|
|
|
|
alias lspci='grc lspci'
|
|
|
|
|
alias lsmod='grc lsmod'
|
|
|
|
|
alias lsof='grc lsof'
|
|
|
|
|
alias getfacl='grc getfacl'
|
|
|
|
|
alias getsebool='grc getsebool'
|
|
|
|
|
alias ulimit='grc ulimit'
|
|
|
|
|
alias uptime='grc uptime'
|
|
|
|
|
alias nmap='grc nmap'
|
|
|
|
|
alias fdisk='grc fdisk'
|
|
|
|
|
alias findmnt='grc findmnt'
|
|
|
|
|
alias free='grc free'
|
|
|
|
|
alias semanage='grc semanage'
|
|
|
|
|
alias sar='grc sar'
|
|
|
|
|
alias ss='grc ss'
|
|
|
|
|
alias sysctl='grc sysctl'
|
|
|
|
|
alias systemctl='grc systemctl'
|
|
|
|
|
alias stat='grc stat'
|
|
|
|
|
alias showmount='grc showmount'
|
|
|
|
|
alias tune2fs='grc tune2fs'
|
|
|
|
|
alias tcpdum='grc tcpdum'
|
2020-04-27 10:22:08 +00:00
|
|
|
|
|
|
|
|
|
btw, () {
|
|
|
|
|
echo " I use"
|
|
|
|
|
echo "[38;2;23;147;209m ▄
|
|
|
|
|
▟█▙
|
|
|
|
|
▟███▙
|
|
|
|
|
▟█████▙
|
|
|
|
|
▟███████▙
|
|
|
|
|
▂▔▀▜██████▙
|
|
|
|
|
▟██▅▂▝▜█████▙
|
|
|
|
|
▟█████████████▙
|
|
|
|
|
▟███████████████▙
|
|
|
|
|
▟█████████████████▙
|
|
|
|
|
▟███████████████████▙
|
|
|
|
|
▟█████████▛▀▀▜████████▙
|
|
|
|
|
▟████████▛ ▜███████▙
|
|
|
|
|
▟█████████ ████████▙
|
|
|
|
|
▟██████████ █████▆▅▄▃▂
|
|
|
|
|
▟██████████▛ ▜█████████▙
|
|
|
|
|
▟██████▀▀▀ ▀▀██████▙
|
|
|
|
|
▟███▀▘ ▝▀███▙
|
|
|
|
|
▟▛▀ ▀▜▙"
|
|
|
|
|
}
|