2023-11-01 16:35:23 +02:00
|
|
|
|
# Fix sudo and doas not expanding aliases
|
|
|
|
|
# see: https://unix.stackexchange.com/questions/148545/why-does-sudo-ignore-aliases
|
|
|
|
|
alias sudo='sudo '
|
|
|
|
|
alias doas='doas '
|
|
|
|
|
|
2019-10-26 20:05:31 +03:00
|
|
|
|
# git shorthands
|
2020-01-13 11:03:59 +02:00
|
|
|
|
alias gc='git commit'
|
|
|
|
|
alias gac='ga && gc'
|
2021-11-13 12:40:11 +02:00
|
|
|
|
alias gs='git status'
|
2020-01-13 11:03:59 +02:00
|
|
|
|
alias gpull='git pull'
|
|
|
|
|
alias gpush='git push'
|
2019-10-26 20:05:31 +03:00
|
|
|
|
|
2024-01-28 19:13:17 +02:00
|
|
|
|
alias o='xdg-open'
|
|
|
|
|
|
2024-01-24 22:48:11 +02:00
|
|
|
|
# Open nvim with diffview
|
|
|
|
|
# Handy plugin for viewing git diffs
|
|
|
|
|
# and handling merges
|
2024-01-25 08:36:38 +02:00
|
|
|
|
alias dv='nvim +DiffviewOpen'
|
2024-01-24 22:48:11 +02:00
|
|
|
|
|
2022-04-22 09:49:47 +03:00
|
|
|
|
# Rename grc alias from forgit since it
|
|
|
|
|
# collides with the grc colorizer
|
|
|
|
|
forgit_revert_commit=fgrc
|
|
|
|
|
|
2021-12-18 00:12:45 +02:00
|
|
|
|
# Modern replacement for ls
|
2023-09-09 12:15:41 +03:00
|
|
|
|
alias ls='eza --icons --git'
|
2021-08-18 09:30:21 +03:00
|
|
|
|
|
2022-08-17 22:02:56 +03:00
|
|
|
|
# Enable command not found handler
|
2022-09-20 18:04:16 +03:00
|
|
|
|
{%@@ if distro_id == "arch" @@%}
|
2022-08-17 22:02:56 +03:00
|
|
|
|
source /usr/share/doc/pkgfile/command-not-found.zsh
|
2022-09-20 18:04:16 +03:00
|
|
|
|
{%@@ elif distro_id == "ubuntu" @@%}
|
2022-08-17 22:02:56 +03:00
|
|
|
|
source /etc/zsh_command_not_found
|
2022-09-20 18:04:16 +03:00
|
|
|
|
{%@@ elif distro_id == "termux" @@%}
|
2022-08-17 21:44:39 +03:00
|
|
|
|
function command_not_found_handler {
|
|
|
|
|
$PREFIX/libexec/termux/command-not-found $1
|
|
|
|
|
}
|
|
|
|
|
{%@@ endif @@%}
|
2021-08-17 20:54:45 +03:00
|
|
|
|
|
2021-11-13 13:07:50 +02:00
|
|
|
|
# search and install/remove packages with fzf
|
2022-09-20 18:04:16 +03:00
|
|
|
|
pi() {
|
2023-11-11 10:51:56 +02:00
|
|
|
|
{%@@ if distro_id == "arch" @@%}
|
|
|
|
|
SELECTED_PKGS="$(paru -Slq | fzf --header='Install packages' -m --preview 'paru -Si {1}' | tr '\n' ' ')"
|
2022-09-20 23:32:21 +03:00
|
|
|
|
{%@@ else @@%}
|
2022-09-20 23:49:40 +03:00
|
|
|
|
SELECTED_PKGS="$(apt list 2>/dev/null | cut -d '/' -f 1 | tail +2 | fzf --header='Install packages' -m --preview 'apt show 2>/dev/null {1}' | tr '\n' ' ')"
|
2022-09-20 23:32:21 +03:00
|
|
|
|
{%@@ endif @@%}
|
2019-10-26 20:05:31 +03:00
|
|
|
|
if [ -n "$SELECTED_PKGS" ]; then
|
2023-11-11 10:51:56 +02:00
|
|
|
|
{%@@ if distro_id == "arch" @@%}
|
|
|
|
|
cmd="paru -S $SELECTED_PKGS"
|
2023-10-30 23:03:13 +02:00
|
|
|
|
{%@@ elif distro_id == "ubuntu" or distro_id == "debian" @@%}
|
2023-03-06 21:47:51 +02:00
|
|
|
|
cmd="doas apt install $SELECTED_PKGS"
|
2023-11-11 10:51:56 +02:00
|
|
|
|
{%@@ elif distro_id == "termux" @@%}
|
|
|
|
|
cmd="apt install $SELECTED_PKGS"
|
2022-09-20 23:32:21 +03:00
|
|
|
|
{%@@ endif @@%}
|
|
|
|
|
|
2021-08-17 19:17:38 +03:00
|
|
|
|
# Append the expanded command to history
|
2022-09-20 23:32:21 +03:00
|
|
|
|
print -s "$cmd"
|
|
|
|
|
|
|
|
|
|
# Finally, excecute the command
|
|
|
|
|
eval "$cmd"
|
2019-10-26 20:05:31 +03:00
|
|
|
|
fi
|
|
|
|
|
}
|
2022-09-20 23:37:20 +03:00
|
|
|
|
|
2023-09-20 16:23:27 +03:00
|
|
|
|
mkcd() {
|
|
|
|
|
mkdir -p $1
|
|
|
|
|
cd $1
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-20 18:04:16 +03:00
|
|
|
|
pr() {
|
2022-09-20 23:37:20 +03:00
|
|
|
|
{%@@ if distro_id == "arch" @@%}
|
2022-09-20 23:47:47 +03:00
|
|
|
|
SELECTED_PKGS="$(paru -Qsq | fzf --header='Remove packages' -m --preview 'paru -Si {1}' | tr '\n' ' ')"
|
2022-09-20 23:37:20 +03:00
|
|
|
|
{%@@ else @@%}
|
2022-09-20 23:49:40 +03:00
|
|
|
|
SELECTED_PKGS="$(apt list --installed 2>/dev/null | cut -d '/' -f 1 | tail +2 | fzf --header='Remove packages' -m --preview 'apt show 2>/dev/null {1}' | tr '\n' ' ')"
|
2022-09-20 23:37:20 +03:00
|
|
|
|
{%@@ endif @@%}
|
2019-10-26 20:05:31 +03:00
|
|
|
|
if [ -n "$SELECTED_PKGS" ]; then
|
2022-09-20 23:37:20 +03:00
|
|
|
|
{%@@ if distro_id == "arch" @@%}
|
2023-03-06 21:47:51 +02:00
|
|
|
|
cmd="paru -Rns $SELECTED_PKGS"
|
2023-10-30 23:03:13 +02:00
|
|
|
|
{%@@ elif distro_id == "ubuntu" or distro_id == "debian" @@%}
|
2023-03-06 21:47:51 +02:00
|
|
|
|
cmd="doas apt remove $SELECTED_PKGS"
|
2022-09-21 00:08:44 +03:00
|
|
|
|
{%@@ elif distro_id == "termux" @@%}
|
2023-03-06 21:47:51 +02:00
|
|
|
|
cmd="apt remove $SELECTED_PKGS"
|
2022-09-20 23:37:20 +03:00
|
|
|
|
{%@@ endif @@%}
|
|
|
|
|
|
2021-08-17 19:17:38 +03:00
|
|
|
|
# Append the expanded command to history
|
2022-09-20 23:37:20 +03:00
|
|
|
|
print -s "$cmd"
|
|
|
|
|
|
|
|
|
|
# Finally, excecute the command
|
|
|
|
|
eval "$cmd"
|
2019-10-26 20:05:31 +03:00
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-06 21:47:51 +02:00
|
|
|
|
{%@@ if profile == "Moria" @@%}
|
|
|
|
|
# Add packages to repo with fzf
|
|
|
|
|
ra() {
|
|
|
|
|
SELECTED_PKGS="$(paru -Slqa | fzf --header='Add packages to repo' -m --preview 'paru -Si {1}' | tr '\n' ' ')"
|
|
|
|
|
if [ -n "$SELECTED_PKGS" ]; then
|
2023-03-10 13:22:34 +02:00
|
|
|
|
cmd="aur sync -S $SELECTED_PKGS"
|
2023-03-06 21:47:51 +02:00
|
|
|
|
|
|
|
|
|
# Append the expanded command to history
|
|
|
|
|
print -s "$cmd"
|
|
|
|
|
|
|
|
|
|
# Finally, excecute the command
|
|
|
|
|
eval "$cmd"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
{%@@ endif @@%}
|
|
|
|
|
|
2022-09-20 18:04:16 +03:00
|
|
|
|
{%@@ if distro_id == "termux" @@%}
|
2022-08-29 00:10:06 +03:00
|
|
|
|
alias gp='okc-gpg'
|
2022-08-29 00:03:04 +03:00
|
|
|
|
{%@@ endif @@%}
|
|
|
|
|
|
2021-11-13 13:07:50 +02:00
|
|
|
|
# find and open man pages with fzf
|
2019-10-26 20:05:31 +03:00
|
|
|
|
fman() {
|
2021-11-13 13:07:50 +02:00
|
|
|
|
man -k . | fzf --prompt='Man> ' | awk '{print $1}' | xargs -r man
|
2019-10-26 20:05:31 +03:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-03 14:10:24 +03:00
|
|
|
|
alias :q='cowsay "You are not in vim anymore"'
|
2019-10-26 20:05:31 +03:00
|
|
|
|
|
2020-03-30 18:21:00 +03:00
|
|
|
|
alias reboot-kodi='systemctl reboot --boot-loader-entry=kodi.conf'
|
|
|
|
|
|
2019-10-26 20:05:31 +03:00
|
|
|
|
# zbar output only data
|
2020-01-13 11:03:59 +02:00
|
|
|
|
alias zbarimg='zbarimg -q --raw'
|
|
|
|
|
alias zbarcam='zbarcam -q --raw'
|
2020-01-12 15:37:15 +02:00
|
|
|
|
|
2020-04-18 13:41:00 +03:00
|
|
|
|
# shorten systemctl and journalctl
|
|
|
|
|
alias sc='systemctl'
|
2020-01-13 11:03:59 +02:00
|
|
|
|
alias scu='systemctl --user'
|
2020-04-18 13:41:00 +03:00
|
|
|
|
alias jc='journalctl'
|
|
|
|
|
alias jcu='journalctl --user'
|
2019-10-26 20:05:31 +03:00
|
|
|
|
|
|
|
|
|
# switch to desktop mode
|
2020-01-13 11:03:59 +02:00
|
|
|
|
alias dock='swaymsg output eDP-1 disable'
|
2019-10-26 20:05:31 +03:00
|
|
|
|
|
2023-05-09 08:58:21 +03:00
|
|
|
|
{%@@ if distro_id != "termux" @@%}
|
2019-10-26 20:05:31 +03:00
|
|
|
|
# move to trash instead of remove
|
2020-01-13 11:03:59 +02:00
|
|
|
|
alias rm='trash'
|
2023-05-09 08:58:21 +03:00
|
|
|
|
{%@@ endif @@%}
|
2019-10-26 20:05:31 +03: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
|
2022-10-10 11:25:20 +03:00
|
|
|
|
doas journalctl --vacuum-size=500M
|
2020-11-20 00:23:02 +02:00
|
|
|
|
paru -Sc
|
2019-10-26 20:05:31 +03:00
|
|
|
|
SPACEAFTER=$(eval "$DFCMD")
|
|
|
|
|
echo "Saved $(calc $SPACEAFTER - $SPACEBEFORE)G of space"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# connect to wireguard
|
2022-10-10 11:25:20 +03:00
|
|
|
|
alias startvpn='doas systemctl start wg-quick@wg0.service'
|
|
|
|
|
alias stopvpn='doas systemctl stop wg-quick@wg0.service'
|
2019-10-26 20:05:31 +03:00
|
|
|
|
|
|
|
|
|
# read qrcode from selection
|
|
|
|
|
qr() { grim -g "$(slurp -d)" - | zbarimg PNG:- }
|
|
|
|
|
|
|
|
|
|
# generate qr code in terminal
|
2020-01-13 11:03:59 +02:00
|
|
|
|
alias qrencode='qrencode -t ansiutf8'
|
2019-10-26 20:05:31 +03:00
|
|
|
|
|
|
|
|
|
# color picker
|
|
|
|
|
cpick() { grim -g "$(slurp -p)" -t ppm - | convert - -format "%[pixel:p{0,0}]" txt:- }
|
|
|
|
|
|
|
|
|
|
#iwctl aliases
|
2020-01-13 11:03:59 +02:00
|
|
|
|
alias i='iwctl station wlan0'
|
2019-10-26 20:05:31 +03:00
|
|
|
|
|
|
|
|
|
# monitor cpu freq
|
2020-01-13 11:03:59 +02:00
|
|
|
|
cpufreq() { watch -n 1 eval "cat /proc/cpuinfo | grep MHz" }
|
2019-10-26 20:05:31 +03:00
|
|
|
|
|
|
|
|
|
# dotdrop
|
2022-08-17 21:41:14 +03:00
|
|
|
|
dotdrop() { source $DOTREPO/secrets/secrets && $DOTREPO/dotdrop/dotdrop.sh --cfg=$DOTREPO/config.toml {%@@ if profile == "Isengard" @@%} -p Isengard{%@@ endif @@%} $@ }
|
2022-08-06 12:18:43 +03:00
|
|
|
|
sdotdrop() { source $DOTREPO/secrets/secrets && sudo -E $DOTREPO/dotdrop/dotdrop.sh --cfg=$DOTREPO/config-root.toml $@ }
|
2019-11-02 08:56:41 +02:00
|
|
|
|
updatesecrets() { bash $DOTREPO/secrets/secrets.sh; chmod 600 $DOTREPO/secrets/secrets }
|
2020-01-13 11:03:59 +02:00
|
|
|
|
compdef _dotdrop-completion.zsh sdotdrop
|
|
|
|
|
alias dotgit='git -C $DOTREPO'
|
2022-08-22 15:01:18 +03:00
|
|
|
|
dotsync() { cd $DOTREPO && gac && gpull && gpush && cd $OLDPWD }
|
2019-10-26 20:05:31 +03:00
|
|
|
|
|
|
|
|
|
# sync password manager
|
|
|
|
|
passync() { pass git pull && pass git push && updatesecrets }
|
|
|
|
|
|
2020-04-14 14:38:51 +03:00
|
|
|
|
update() {
|
|
|
|
|
all() {
|
2023-12-04 10:14:51 +02:00
|
|
|
|
dotfiles
|
2022-08-17 14:28:28 +03:00
|
|
|
|
packages
|
2020-04-14 14:38:51 +03:00
|
|
|
|
{%@@ if profile == "Moria" @@%}
|
2020-12-25 10:59:03 +02:00
|
|
|
|
repo
|
2020-04-15 13:09:11 +03:00
|
|
|
|
docker-update
|
2020-04-14 14:38:51 +03:00
|
|
|
|
{%@@ endif @@%}
|
2022-03-05 08:38:19 +02:00
|
|
|
|
plugins
|
2020-04-14 14:38:51 +03:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-17 14:28:28 +03:00
|
|
|
|
packages() {
|
2022-09-20 18:04:16 +03:00
|
|
|
|
{%@@ if distro_id == "arch" @@%}
|
2023-10-04 10:29:05 +03:00
|
|
|
|
paru -Syu --noconfirm
|
2023-10-30 23:03:13 +02:00
|
|
|
|
{%@@ elif distro_id == "ubuntu" or distro_id == "debian" @@%}
|
2022-10-10 11:25:20 +03:00
|
|
|
|
doas apt update && doas apt full-upgrade -y && doas apt autoremove -y && doas apt autoclean -y
|
2022-09-20 18:04:16 +03:00
|
|
|
|
{%@@ elif distro_id == "termux" @@%}
|
2023-11-11 10:51:56 +02:00
|
|
|
|
pkg update && pkg upgrade --yes
|
2023-10-03 10:40:06 +03:00
|
|
|
|
{%@@ endif @@%}
|
2023-11-11 10:51:56 +02:00
|
|
|
|
{%@@ if distro_id == "termux" or distro_id == "ubuntu" or distro_id == "debian" @@%}
|
2023-10-03 10:40:06 +03:00
|
|
|
|
pip-update-installed
|
|
|
|
|
cargo-update-installed
|
2022-08-17 14:28:28 +03:00
|
|
|
|
{%@@ endif @@%}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-14 14:38:51 +03:00
|
|
|
|
plugins() {
|
2022-08-23 09:28:07 +03:00
|
|
|
|
echo "Updating NeoVim plugins"
|
2023-12-04 10:14:51 +02:00
|
|
|
|
nvim --headless -c "Lazy! restore" -c 'TSUpdateSync' -c 'MasonToolsUpdate' -c 'qa'
|
2020-04-14 14:38:51 +03:00
|
|
|
|
zinit self-update
|
|
|
|
|
zinit update -p
|
2022-10-10 11:29:25 +03:00
|
|
|
|
{%@@ if profile == "Moria" @@%}
|
2020-04-14 14:38:51 +03:00
|
|
|
|
$HOME/.tmux/plugins/tpm/bin/update_plugins all
|
2022-10-10 11:29:25 +03:00
|
|
|
|
{%@@ endif @@%}
|
2020-04-14 14:38:51 +03:00
|
|
|
|
}
|
|
|
|
|
|
2023-10-03 10:40:06 +03:00
|
|
|
|
pip-update-installed() {
|
|
|
|
|
pip install --upgrade $(pip list --outdated | tail -n +3 | awk '{print $1}')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cargo-update-installed() {
|
|
|
|
|
cargo install-update -a
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 09:47:44 +03:00
|
|
|
|
{%@@ if profile == "Moria" @@%}
|
|
|
|
|
repo() {
|
|
|
|
|
aur sync -Su --margs --noconfirm
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-18 09:16:26 +03:00
|
|
|
|
local docker-update() {
|
2022-08-17 14:28:28 +03:00
|
|
|
|
prevpwddocker=$PWD
|
2020-11-21 15:37:58 +02:00
|
|
|
|
for dir in $HOME/git/dotfiles/docker/*; do
|
2020-04-14 14:38:51 +03:00
|
|
|
|
cd $dir
|
2022-08-17 14:28:28 +03:00
|
|
|
|
if [[ -f "$dir/DISABLED" ]]; then
|
2022-04-11 15:52:25 +03:00
|
|
|
|
echo "$(basename $dir) stack is disabled, skipping..."
|
2022-04-10 13:28:26 +03:00
|
|
|
|
else
|
2022-08-17 14:28:28 +03:00
|
|
|
|
dct -f $dir/docker-compose.toml pull
|
|
|
|
|
dct -f $dir/docker-compose.toml up -d
|
2022-04-10 13:28:26 +03:00
|
|
|
|
fi
|
2022-04-21 09:09:43 +03:00
|
|
|
|
cd ..
|
2020-04-14 14:38:51 +03:00
|
|
|
|
done
|
2022-08-17 14:28:28 +03:00
|
|
|
|
cd $prevpwddocker
|
2022-08-01 11:15:30 +03:00
|
|
|
|
docker system prune -af --volumes
|
2023-10-18 09:16:26 +03:00
|
|
|
|
|
|
|
|
|
occ upgrade
|
|
|
|
|
occ app:update --all
|
|
|
|
|
occ db:add-missing-indices
|
2020-04-14 14:38:51 +03:00
|
|
|
|
}
|
2023-09-11 15:21:19 +03:00
|
|
|
|
{%@@ endif @@%}
|
2020-04-14 14:38:51 +03:00
|
|
|
|
|
2023-09-11 15:19:57 +03:00
|
|
|
|
dotfiles() {
|
|
|
|
|
dotgit pull
|
|
|
|
|
dotdrop install
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-11 15:35:20 +03:00
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
|
packages # Update only packages if no option was provided
|
|
|
|
|
else
|
|
|
|
|
case "$1" in
|
|
|
|
|
all)
|
|
|
|
|
all
|
|
|
|
|
;;
|
|
|
|
|
dotfiles)
|
|
|
|
|
dotfiles
|
|
|
|
|
;;
|
|
|
|
|
plugins)
|
|
|
|
|
plugins
|
|
|
|
|
;;
|
|
|
|
|
{%@@ if profile == "Moria" @@%}
|
|
|
|
|
docker)
|
|
|
|
|
docker-update
|
|
|
|
|
;;
|
|
|
|
|
repo)
|
|
|
|
|
repo
|
|
|
|
|
;;
|
|
|
|
|
{%@@ endif @@%}
|
|
|
|
|
*)
|
|
|
|
|
echo "Unknown option: $1"
|
|
|
|
|
return 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
fi
|
2020-04-14 14:03:21 +03:00
|
|
|
|
}
|
2019-10-26 20:05:31 +03:00
|
|
|
|
|
2023-09-11 15:33:01 +03:00
|
|
|
|
_update() {
|
|
|
|
|
local commands=(
|
|
|
|
|
"all:Update everything"
|
|
|
|
|
"dotfiles:Update dotfiles"
|
|
|
|
|
"plugins:Update plugins for NeoVim and ZSH"
|
|
|
|
|
{%@@ if profile == "Moria" @@%}
|
|
|
|
|
"repo:Update packages in Korhonen AUR repository"
|
|
|
|
|
"docker:Update all Docker containers"
|
|
|
|
|
{%@@ endif @@%}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
_arguments \
|
|
|
|
|
'1: :->command' \
|
|
|
|
|
'*:: :->args'
|
|
|
|
|
|
|
|
|
|
case "$state" in
|
|
|
|
|
(command)
|
|
|
|
|
_describe -t commands 'available commands' commands
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
compdef _update update
|
|
|
|
|
|
2019-10-26 20:05:31 +03: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
|
2022-10-10 11:25:20 +03:00
|
|
|
|
alias reflect='doas reflector --latest 200 --threads 8 --verbose --protocol http --protocol https --sort rate --save /etc/pacman.d/mirrorlist'
|
2019-10-26 20:05:31 +03:00
|
|
|
|
|
|
|
|
|
# default icon for notify-send
|
2020-01-13 11:03:59 +02:00
|
|
|
|
alias notify-send='notify-send --icon=alarm'
|
2019-10-30 00:43:03 +02:00
|
|
|
|
|
2020-03-03 16:54:32 +02: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 14:50:06 +02: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 08:32:25 +02:00
|
|
|
|
|
2022-03-29 23:00:50 +03:00
|
|
|
|
# Switch to different yubikey
|
2022-03-29 23:02:07 +03:00
|
|
|
|
alias switch-yubikey='gpg-connect-agent "scd serialno" "learn --force" /bye'
|
2022-03-29 23:00:50 +03:00
|
|
|
|
|
2020-04-27 13:22:08 +03:00
|
|
|
|
btw, () {
|
|
|
|
|
echo " I use"
|
|
|
|
|
echo "[38;2;23;147;209m ▄
|
|
|
|
|
▟█▙
|
|
|
|
|
▟███▙
|
|
|
|
|
▟█████▙
|
|
|
|
|
▟███████▙
|
|
|
|
|
▂▔▀▜██████▙
|
|
|
|
|
▟██▅▂▝▜█████▙
|
|
|
|
|
▟█████████████▙
|
|
|
|
|
▟███████████████▙
|
|
|
|
|
▟█████████████████▙
|
|
|
|
|
▟███████████████████▙
|
|
|
|
|
▟█████████▛▀▀▜████████▙
|
|
|
|
|
▟████████▛ ▜███████▙
|
|
|
|
|
▟█████████ ████████▙
|
|
|
|
|
▟██████████ █████▆▅▄▃▂
|
|
|
|
|
▟██████████▛ ▜█████████▙
|
|
|
|
|
▟██████▀▀▀ ▀▀██████▙
|
|
|
|
|
▟███▀▘ ▝▀███▙
|
|
|
|
|
▟▛▀ ▀▜▙"
|
|
|
|
|
}
|
2022-02-26 13:18:03 +02: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
|
|
|
|
|
|
2022-09-20 19:45:07 +03:00
|
|
|
|
yj -ty < $file_path | docker compose -f - $@
|
2022-02-26 13:18:03 +02:00
|
|
|
|
}
|
2022-11-06 09:43:20 +02:00
|
|
|
|
|
|
|
|
|
alias dslr-webcam='pkill -f gphoto2; gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0'
|
2023-05-08 11:22:05 +03:00
|
|
|
|
|
|
|
|
|
clock() {
|
|
|
|
|
while true; do
|
|
|
|
|
printf '%s\r' "$(date)"
|
2023-05-08 11:26:52 +03:00
|
|
|
|
sleep 0.1
|
2023-05-08 11:22:05 +03:00
|
|
|
|
done
|
|
|
|
|
}
|
2023-07-11 14:23:13 +03:00
|
|
|
|
|
|
|
|
|
# Change file extension made easy
|
|
|
|
|
chext() {
|
|
|
|
|
file="$1"
|
|
|
|
|
new_ext="$2"
|
|
|
|
|
dest="${file%.*}.$new_ext"
|
|
|
|
|
|
|
|
|
|
help() {
|
|
|
|
|
printf "Change file extension\nUsage: chext file new_extension\nFor example: chext my_script.sh zsh"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
|
|
|
|
help
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ $# -lt 2 ]; then
|
|
|
|
|
help
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ ! -e "$1" ]; then
|
|
|
|
|
echo "$file: no such file or directory"
|
|
|
|
|
help
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
mv "$file" "$dest"
|
|
|
|
|
}
|