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'
|
2021-11-13 10:40:11 +00:00
|
|
|
|
alias gs='git status'
|
2020-01-13 09:03:59 +00:00
|
|
|
|
alias gpull='git pull'
|
|
|
|
|
alias gpush='git push'
|
2019-10-26 17:05:31 +00:00
|
|
|
|
|
2022-04-22 06:49:47 +00:00
|
|
|
|
# Rename grc alias from forgit since it
|
|
|
|
|
# collides with the grc colorizer
|
|
|
|
|
forgit_revert_commit=fgrc
|
|
|
|
|
|
2021-12-17 22:12:45 +00:00
|
|
|
|
# Modern replacement for ls
|
2021-08-18 06:30:21 +00:00
|
|
|
|
alias ls='exa'
|
|
|
|
|
|
2022-08-17 19:02:56 +00:00
|
|
|
|
# Enable command not found handler
|
|
|
|
|
{%@@ if os == "arch" @@%}
|
|
|
|
|
source /usr/share/doc/pkgfile/command-not-found.zsh
|
|
|
|
|
{%@@ elif os == "ubuntu" @@%}
|
|
|
|
|
source /etc/zsh_command_not_found
|
|
|
|
|
{%@@ elif os == "termux" @@%}
|
2022-08-17 18:44:39 +00:00
|
|
|
|
function command_not_found_handler {
|
|
|
|
|
$PREFIX/libexec/termux/command-not-found $1
|
|
|
|
|
}
|
|
|
|
|
{%@@ endif @@%}
|
2021-08-17 17:54:45 +00:00
|
|
|
|
|
2022-08-18 07:01:59 +00:00
|
|
|
|
{%@@ if os == "arch" @@%}
|
2021-11-13 11:07:50 +00:00
|
|
|
|
# search and install/remove packages with fzf
|
2020-11-19 22:23:02 +00:00
|
|
|
|
pi() {
|
2021-11-13 11:07:50 +00:00
|
|
|
|
SELECTED_PKGS="$(paru -Slq | fzf --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
|
|
|
|
|
}
|
2020-11-19 22:23:02 +00:00
|
|
|
|
pr() {
|
2021-11-13 11:07:50 +00:00
|
|
|
|
SELECTED_PKGS="$(paru -Qsq | fzf --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
|
|
|
|
|
}
|
2022-08-18 07:01:59 +00:00
|
|
|
|
{%@@ endif @@%}
|
2019-10-26 17:05:31 +00:00
|
|
|
|
|
2022-08-28 21:03:04 +00:00
|
|
|
|
{%@@ if os == "termux" @@%}
|
2022-08-28 21:10:06 +00:00
|
|
|
|
alias gp='okc-gpg'
|
2022-08-28 21:03:04 +00:00
|
|
|
|
{%@@ endif @@%}
|
|
|
|
|
|
2021-11-13 11:07:50 +00:00
|
|
|
|
# find and open man pages with fzf
|
2019-10-26 17:05:31 +00:00
|
|
|
|
fman() {
|
2021-11-13 11:07:50 +00:00
|
|
|
|
man -k . | fzf --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
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
|
# 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
|
2022-08-17 18:41:14 +00:00
|
|
|
|
dotdrop() { source $DOTREPO/secrets/secrets && $DOTREPO/dotdrop/dotdrop.sh --cfg=$DOTREPO/config.toml {%@@ if profile == "Isengard" @@%} -p Isengard{%@@ endif @@%} $@ }
|
2022-08-06 09:18:43 +00:00
|
|
|
|
sdotdrop() { source $DOTREPO/secrets/secrets && sudo -E $DOTREPO/dotdrop/dotdrop.sh --cfg=$DOTREPO/config-root.toml $@ }
|
2019-11-02 06:56:41 +00:00
|
|
|
|
updatesecrets() { bash $DOTREPO/secrets/secrets.sh; chmod 600 $DOTREPO/secrets/secrets }
|
2020-01-13 09:03:59 +00:00
|
|
|
|
compdef _dotdrop-completion.zsh sdotdrop
|
|
|
|
|
alias dotgit='git -C $DOTREPO'
|
2022-08-22 12:01:18 +00:00
|
|
|
|
dotsync() { cd $DOTREPO && gac && gpull && gpush && cd $OLDPWD }
|
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() {
|
2022-08-17 11:28:28 +00:00
|
|
|
|
packages
|
2020-04-14 11:38:51 +00:00
|
|
|
|
{%@@ if profile == "Moria" @@%}
|
2020-12-25 08:59:03 +00:00
|
|
|
|
repo
|
2020-04-15 10:09:11 +00:00
|
|
|
|
docker-update
|
2020-04-14 11:38:51 +00:00
|
|
|
|
{%@@ endif @@%}
|
2022-03-05 06:38:19 +00:00
|
|
|
|
plugins
|
2020-04-14 11:38:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-17 11:28:28 +00:00
|
|
|
|
packages() {
|
|
|
|
|
{%@@ if os == "arch" @@%}
|
|
|
|
|
paru
|
|
|
|
|
{%@@ elif os == "ubuntu" @@%}
|
|
|
|
|
sudo apt update && sudo apt full-upgrade -y && sudo apt autoremove -y && sudo apt autoclean -y
|
|
|
|
|
{%@@ elif os == "termux" @@%}
|
|
|
|
|
pkg update
|
|
|
|
|
{%@@ endif @@%}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-14 11:38:51 +00:00
|
|
|
|
plugins() {
|
2022-08-23 06:28:07 +00:00
|
|
|
|
echo "Updating NeoVim plugins"
|
|
|
|
|
nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'
|
|
|
|
|
echo "Updating NeoVim TreeSitter"
|
2022-08-18 10:09:26 +00:00
|
|
|
|
nvim --headless +TSUpdateSync +qa
|
2020-04-14 11:38:51 +00:00
|
|
|
|
zinit self-update
|
|
|
|
|
zinit update -p
|
|
|
|
|
$HOME/.tmux/plugins/tpm/bin/update_plugins all
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 06:47:44 +00:00
|
|
|
|
{%@@ if profile == "Moria" @@%}
|
|
|
|
|
repo() {
|
|
|
|
|
aur sync -Su --margs --noconfirm
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-15 10:09:11 +00:00
|
|
|
|
docker-update() {
|
2022-08-17 11:28:28 +00:00
|
|
|
|
prevpwddocker=$PWD
|
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
|
2022-08-17 11:28:28 +00:00
|
|
|
|
if [[ -f "$dir/DISABLED" ]]; then
|
2022-04-11 12:52:25 +00:00
|
|
|
|
echo "$(basename $dir) stack is disabled, skipping..."
|
2022-04-10 10:28:26 +00:00
|
|
|
|
else
|
2022-08-17 11:28:28 +00:00
|
|
|
|
dct -f $dir/docker-compose.toml pull
|
|
|
|
|
dct -f $dir/docker-compose.toml up -d
|
2022-04-10 10:28:26 +00:00
|
|
|
|
fi
|
2022-04-21 06:09:43 +00:00
|
|
|
|
cd ..
|
2020-04-14 11:38:51 +00:00
|
|
|
|
done
|
2022-08-17 11:28:28 +00:00
|
|
|
|
cd $prevpwddocker
|
2022-08-01 08:15:30 +00:00
|
|
|
|
docker system prune -af --volumes
|
2020-04-14 11:38:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 06:47:44 +00:00
|
|
|
|
{%@@ endif @@%}
|
2020-04-14 11:38:51 +00:00
|
|
|
|
case "$1" in
|
|
|
|
|
all)
|
|
|
|
|
all
|
|
|
|
|
;;
|
|
|
|
|
plugins)
|
|
|
|
|
plugins
|
|
|
|
|
;;
|
2022-08-03 06:41:20 +00:00
|
|
|
|
{%@@ if profile == "Moria" @@%}
|
2020-04-14 11:38:51 +00:00
|
|
|
|
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
|
|
|
|
|
;;
|
2022-08-03 06:41:20 +00:00
|
|
|
|
{%@@ endif @@%}
|
2020-04-14 11:38:51 +00:00
|
|
|
|
*)
|
2022-08-17 11:28:28 +00:00
|
|
|
|
packages
|
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
|
|
|
|
|
|
|
|
|
# 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"'
|
|
|
|
|
|
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
|
|
|
|
|
2022-03-29 20:00:50 +00:00
|
|
|
|
# Switch to different yubikey
|
2022-03-29 20:02:07 +00:00
|
|
|
|
alias switch-yubikey='gpg-connect-agent "scd serialno" "learn --force" /bye'
|
2022-03-29 20:00:50 +00:00
|
|
|
|
|
2020-04-27 10:22:08 +00:00
|
|
|
|
btw, () {
|
|
|
|
|
echo " I use"
|
|
|
|
|
echo "[38;2;23;147;209m ▄
|
|
|
|
|
▟█▙
|
|
|
|
|
▟███▙
|
|
|
|
|
▟█████▙
|
|
|
|
|
▟███████▙
|
|
|
|
|
▂▔▀▜██████▙
|
|
|
|
|
▟██▅▂▝▜█████▙
|
|
|
|
|
▟█████████████▙
|
|
|
|
|
▟███████████████▙
|
|
|
|
|
▟█████████████████▙
|
|
|
|
|
▟███████████████████▙
|
|
|
|
|
▟█████████▛▀▀▜████████▙
|
|
|
|
|
▟████████▛ ▜███████▙
|
|
|
|
|
▟█████████ ████████▙
|
|
|
|
|
▟██████████ █████▆▅▄▃▂
|
|
|
|
|
▟██████████▛ ▜█████████▙
|
|
|
|
|
▟██████▀▀▀ ▀▀██████▙
|
|
|
|
|
▟███▀▘ ▝▀███▙
|
|
|
|
|
▟▛▀ ▀▜▙"
|
|
|
|
|
}
|
2022-02-26 11:18:03 +00:00
|
|
|
|
|
|
|
|
|
# docker-compose with TOML
|
|
|
|
|
dct() {
|
|
|
|
|
local file_path=('./docker-compose.toml')
|
|
|
|
|
|
|
|
|
|
zmodload zsh/zutil
|
|
|
|
|
zparseopts -D -K -- \
|
|
|
|
|
f:=file_path ||
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
file_path=${file_path[-1]}
|
|
|
|
|
|
|
|
|
|
if [[ ! -a "$file_path" ]]; then
|
|
|
|
|
echo "File $file_path does not exist!"
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
yj -ty < $file_path | docker-compose -f - $@
|
|
|
|
|
}
|