233 lines
9.8 KiB
Plaintext
233 lines
9.8 KiB
Plaintext
# ~/.config/zsh_confs/20_aliases: my [zsh] shell aliases
|
|
|
|
# export everything first
|
|
#export TERM="xterm-256color"
|
|
export TIMEFMT=$'\nJob\t%J\n\nCPU\t%P\nuser\t%U\nsystem\t%S\ntotal\t%E'
|
|
export LANG=en_IN.UTF-8
|
|
|
|
if command -v nvim > /dev/null; then
|
|
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|
export EDITOR=$(command -v nvim)
|
|
export SYSTEMD_EDITOR=$(command -v nvim)
|
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
|
export EDITOR=$(command -v nvim)
|
|
fi
|
|
fi
|
|
|
|
# add dir to PATH if present
|
|
# precedence from top (lowest) to bottom (highest)
|
|
if command -v rustup > /dev/null; then
|
|
which rust-analyzer > /dev/null || export PATH="$(rustc --print sysroot)/bin":$PATH
|
|
# rust-analyzer is in "$(rustc --print sysroot)/bin" instead of $HOME/.cargo/bin :(
|
|
# rust-analyzer needs to be in $PATH for good Rust support in Neovim
|
|
# see https://github.com/rust-lang/rustup/issues/2411
|
|
fi
|
|
[[ -d "$HOME/.cargo/bin" ]] && export PATH=$HOME/.cargo/bin:$PATH
|
|
[[ -d /usr/sbin ]] && export PATH=/usr/sbin:$PATH
|
|
[[ -d /usr/local/sbin ]] && export PATH=/usr/local/sbin:$PATH
|
|
[[ -d /usr/bin ]] && export PATH=/usr/bin:$PATH
|
|
[[ -d /usr/local/bin ]] && export PATH=/usr/local/bin:$PATH
|
|
[[ -d "$HOME/.local/bin" ]] && export PATH=$HOME/.local/bin:$PATH
|
|
typeset -U PATH
|
|
|
|
# common aliases
|
|
alias dotfiles="git --git-dir=$HOME/.dotfiles --work-tree=$HOME"
|
|
alias nixrebuild="nixos-rebuild boot"
|
|
alias nixupgrade="nixos-rebuild boot --upgrade"
|
|
alias flushSSH="ssh-keygen -R"
|
|
alias mtr='mtr --show-ips --displaymode 0 -o "LDR AGJMXI"'
|
|
alias update="source $HOME/.zshrc" # other files are sourced automatically
|
|
alias custcp="rsync --fsync --verbose --recursive --size-only --human-readable --progress --stats --itemize-changes"
|
|
alias pysort="$HOME/.local/scripts/other-common-scripts/sort.py"
|
|
alias download="aria2c -x 16 -k 1M --file-allocation=none --continue=false --seed-time=0"
|
|
alias showsslvalidity="~/.scripts/common-scripts/domain_ssl_validity.sh"
|
|
alias ytdown="yt-dlp --config-location $HOME/.config/yt-dlp/norm_config --external-downloader aria2c"
|
|
alias playdl="yt-dlp --config-location $HOME/.config/yt-dlp/plst_config --external-downloader aria2c"
|
|
alias ytslow="yt-dlp --config-location $HOME/.config/yt-dlp/norm_config --no-part --concurrent-fragments 1 --limit-rate 4M"
|
|
alias rgi="rg --hidden -i"
|
|
alias rgv="rg --hidden -v"
|
|
alias rgvi="rg --hidden -vi"
|
|
alias rgiv="rg --hidden -vi"
|
|
alias gcommitm="git commit -m"
|
|
alias unxz="unxz -k"
|
|
alias clearxclip="xsel -bc"
|
|
alias olddig="/usr/bin/dig"
|
|
alias digdig="/usr/bin/dig"
|
|
alias dig="/usr/bin/dog"
|
|
alias sudo="sudo "
|
|
alias doas="doas "
|
|
|
|
if command -v batcat > /dev/null; then
|
|
alias bat="batcat"
|
|
fi
|
|
|
|
# OS/hostname specific aliases
|
|
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|
# common ls aliases
|
|
alias l="ls --group-directories-first --color=auto -v"
|
|
alias ll="ls --group-directories-first --color=auto -1lv --time-style=long-iso"
|
|
alias la="ls --group-directories-first --color=auto -1Av --time-style=long-iso"
|
|
alias lo="ls --group-directories-first --color=auto -1v"
|
|
alias llh="ls --group-directories-first --color=auto -1hlv --time-style=long-iso"
|
|
alias lah="ls --group-directories-first --color=auto -1Ahlv --time-style=long-iso"
|
|
alias ldt="ls --group-directories-first --color=auto -1Altv --time-style=long-iso"
|
|
|
|
# common grep aliases
|
|
alias grep="grep --color=auto"
|
|
alias greplv="grep --color=auto -lv"
|
|
alias grepli="grep --color=auto -li"
|
|
alias grepv="grep --color=auto -v"
|
|
alias grepi="grep --color=auto -i"
|
|
|
|
# ssh related aliases
|
|
alias flameboi="ssh flameboi.lan"
|
|
alias sentinel="ssh sentinel.lan"
|
|
alias reddish="ssh reddish.lan"
|
|
alias vasudev="ssh vasu.dev"
|
|
alias riscyrock="ssh riscy.rock"
|
|
alias rustyvm="ssh rusty.vm"
|
|
|
|
# ping related aliases
|
|
alias pingflameboi="ping 10.0.0.13"
|
|
alias pingsentinel="ping 10.0.0.14"
|
|
alias pingreddish="ping 10.0.0.19"
|
|
|
|
# aliases for flatpak
|
|
alias flatpakupdates="flatpak remote-ls --updates flathub"
|
|
alias flatpakautoremove="flatpak remove --unused --delete-data"
|
|
|
|
# other common aliases
|
|
alias ping="ping -W 0.1 -O"
|
|
alias pmount="mount -o gid=pratham,uid=pratham"
|
|
alias mpv="/usr/bin/mpv --geometry=60% --vo=gpu --hwdec=vaapi"
|
|
alias pbcopy="xsel --clipboard --input"
|
|
if command -v doas > /dev/null; then
|
|
alias serialterm="clear && doas picocom --quiet -b 115200 /dev/ttyUSB0"
|
|
else
|
|
alias serialterm="clear && sudo picocom --quiet -b 115200 /dev/ttyUSB0"
|
|
fi
|
|
|
|
|
|
if [[ "$MACHINE_HOSTNAME" == "flameboi" || "$MACHINE_HOSTNAME" == "vasudev" || "$MACHINE_HOSTNAME" == "rustyvm" ]]; then
|
|
alias suslock="$HOME/.local/scripts/window-manager/lock-and-suspend.sh"
|
|
alias drivetemp="hdparm -CH /dev/sda /dev/sdb /dev/sdc /dev/sdd"
|
|
alias paru="LESS=SRX paru"
|
|
alias undeb="dpkg-deb -xv"
|
|
|
|
alias pacrm="pacman -Rsu"
|
|
alias pacinstall="pacman -S"
|
|
|
|
alias pkgupgrade="pacman -Syyu"
|
|
alias pkgsearch="pacman -Ss"
|
|
alias pkgrevdeps="pacman -Sii"
|
|
alias pkgfileof="pacman -Qo"
|
|
alias pkgshowfiles="pacman -Fl"
|
|
alias pkgautoremove="pacman -R $(pacman -Qdtq)"
|
|
|
|
# aliases useful when using a WM
|
|
alias gnomecontrolcenter="XDG_CURRENT_DESKTOP=GNOME gnome-control-center"
|
|
alias gnomecc="XDG_CURRENT_DESKTOP=GNOME gnome-control-center"
|
|
|
|
# chown everything in /heathen_disk
|
|
owndisk() {
|
|
OWNDIR=/heathen_disk
|
|
sudo chmod 774 -R "$OWNDIR"
|
|
sudo /usr/bin/chown pratham:pratham -R "$OWNDIR"
|
|
find "$OWNDIR" -type f -exec chmod 660 {} \;
|
|
find "$OWNDIR" -type f -name "._*" -exec rm -iv {} \;
|
|
find "$OWNDIR" -type f -name "*.DS_Store" -exec rm -iv {} \;
|
|
}
|
|
|
|
elif [[ "$MACHINE_HOSTNAME" == "reddish" ]]; then
|
|
alias clear="/usr/bin/clear && printf '\e[3J'"
|
|
alias drivetemp="hdparm -CH /dev/sda /dev/sdb"
|
|
|
|
# aliases for container management
|
|
ALL_CONTAINERS=("container-uptime-vishnu.service" \
|
|
"container-caddy-vishwambhar.service" \
|
|
"container-gitea-govinda.service" \
|
|
"container-gitea-chitragupta.service" \
|
|
"container-hugo-vaikunthnatham.service" \
|
|
"container-nextcloud-govinda.service" \
|
|
"container-nextcloud-chitragupta.service" \
|
|
"container-hugo-mahayogi.service" \
|
|
"container-gotify-akashvani.service" \
|
|
"container-transmission-raadhe.service")
|
|
|
|
alias containerupdate="podman auto-update --dry-run | grep -v 'false'"
|
|
alias containerpruneimages="podman system prune -a"
|
|
|
|
containerdisableall() {
|
|
for INDV_CONTAINER in "${ALL_CONTAINERS[@]}"; do
|
|
systemctl --user disable "$INDV_CONTAINER"
|
|
done
|
|
}
|
|
|
|
containerenableall() {
|
|
for INDV_CONTAINER in "${ALL_CONTAINERS[@]}"; do
|
|
systemctl --user enable "$INDV_CONTAINER"
|
|
done
|
|
}
|
|
|
|
containerstopall() {
|
|
for INDV_CONTAINER in "${ALL_CONTAINERS[@]}"; do
|
|
if [[ $(systemctl --user is-enabled "$INDV_CONTAINER") -eq 0 ]]; then
|
|
systemctl --user is-active --quiet service "$INDV_CONTAINER" && systemctl --user stop "$INDV_CONTAINER" && echo "$INDV_CONTAINER: stopped"
|
|
fi
|
|
done
|
|
}
|
|
|
|
containerstartall() {
|
|
for (( idx=${#ALL_CONTAINERS[@]} ; idx>0 ; idx-- )) ; do
|
|
INDV_CONTAINER=${ALL_CONTAINERS[idx]}
|
|
if [[ $(systemctl --user is-enabled "$INDV_CONTAINER") -eq 0 ]]; then
|
|
systemctl --user restart "$INDV_CONTAINER" && echo "$INDV_CONTAINER: started"
|
|
fi
|
|
done
|
|
}
|
|
|
|
containerstats() {
|
|
systemctl --user status "${ALL_CONTAINERS[@]}" | grep '(running) since\|●\|ago'
|
|
TOTAL_RUNNING=$(podman ps --format '{{.Names}}' | wc -l)
|
|
TOTAL_CONTAINERS=$(podman container list -a --format '{{.Names}}' | wc -l)
|
|
|
|
echo -e "Running:\t${TOTAL_RUNNING}/10"
|
|
echo -e "Containers:\t${TOTAL_CONTAINERS}/10"
|
|
}
|
|
|
|
# rebuild ZFS DKMS automatically/manually
|
|
rebuildzfs() {
|
|
# equivalent of `uname -r` but for _all_ kernels that are installed
|
|
ALL_KERNELS=($(sudo dnf info kernel | grep Source | awk '{print $3}' | sed "s/kernel-//g" | sed "s/src.rpm/$(uname -m)/g"))
|
|
# get the latest version of ZFS (`zfs/2.1.7`)
|
|
LATEST_ZFS_VER=$(git ls-remote --refs --tags https://github.com/openzfs/zfs | cut --delimiter='/' --fields=3 | sort --version-sort | tail --lines=2 | head --lines=1 | sed "s/-/\//g")
|
|
|
|
for KERNEL in "${ALL_KERNELS[@]}"; do
|
|
if [[ $(sudo dkms status -k ${KERNEL} | grep "$LATEST_ZFS_VER" | grep "installed") -eq 0 ]]; then
|
|
echo -ne "ZFS is installed for $KERNEL. You may REINSTALL it using the following command:\nsudo dkms install ${LATEST_ZFS_VER} -k ${KERNEL}\n\n"
|
|
else
|
|
echo "ZFS is NOT installed for $KERNEL. Building and intalling..."
|
|
sudo dkms install "${LATEST_ZFS_VER}" -k "${KERNEL}"
|
|
echo -ne "\n--------------------------------------------------------------------------------\n"
|
|
fi
|
|
done
|
|
}
|
|
fi
|
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
|
|
|
[[ -d /sbin ]] && export PATH=/sbin:$PATH
|
|
[[ -d /bin ]] && export PATH=/bin:$PATH
|
|
typeset -U PATH
|
|
|
|
# other aliases
|
|
alias xargs="/usr/local/opt/findutils/libexec/gnubin/xargs"
|
|
alias tmux="/usr/local/bin/tmux -f $HOME/.config/tmux/tmux.conf"
|
|
alias clear="/usr/bin/clear && printf '\e[3J'"
|
|
alias ktb="sudo pkill TouchBarServer; killall ControlStrip"
|
|
alias mpv="/usr/local/bin/mpv --vo=libmpv"
|
|
fi
|
|
|
|
# source functions
|
|
ALIAS_FUNC_CONF=$HOME/.config/zsh_confs/21_alias_funcs
|
|
[ -f $ALIAS_FUNC_CONF ] && source $ALIAS_FUNC_CONF
|