231 lines
9.7 KiB
Plaintext
231 lines
9.7 KiB
Plaintext
# ~/.config/zsh_confs/20_aliases: my [zsh] shell aliases
|
|
|
|
# hostname
|
|
MACHINE_HOSTNAME=$(cat /etc/hostname)
|
|
|
|
# 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 [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|
export EDITOR=/usr/bin/nvim
|
|
export SYSTEMD_EDITOR=/usr/bin/nvim
|
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
|
export EDITOR=/usr/local/bin/nvim
|
|
fi
|
|
|
|
# add dir to PATH if present
|
|
# precedence from top (lowest) to bottom (highest)
|
|
if command -v rustup > /dev/null; then
|
|
RUSTUP_TRIPLET=$(rustup show active-toolchain | awk '{print $1}')
|
|
RUSTUP_PATH="$HOME/.rustup/toolchains/$RUSTUP_TRIPLET/bin"
|
|
[[ -d "$RUSTUP_PATH" ]] && export PATH=$RUSTUP_PATH:$PATH
|
|
# rust-analyzer is in $RUSTUP_PATH 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 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/.scripts/common-scripts/sort.py"
|
|
alias download="aria2c -x 16 -k 1M --file-allocation=none --continue=false --seed-time=0"
|
|
alias vim="nvim"
|
|
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 gcommitm="git commit -m"
|
|
alias clearxclip="xsel -bc"
|
|
alias olddig="dig"
|
|
alias dig="dog"
|
|
alias sudo="sudo "
|
|
|
|
if command -v batcat > /dev/null; then
|
|
alias bat="batcat"
|
|
fi
|
|
|
|
if command -v doas > /dev/null; then
|
|
unalias sudo
|
|
alias sudo="doas "
|
|
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"
|
|
alias la="ls --group-directories-first --color=auto -1Av"
|
|
alias lo="ls --group-directories-first --color=auto -1v"
|
|
alias llh="ls --group-directories-first --color=auto -1hlv"
|
|
alias lah="ls --group-directories-first --color=auto -1Ahlv"
|
|
alias ldt="ls --group-directories-first --color=auto -1Altv"
|
|
|
|
# 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 pratham@flameboi.lan"
|
|
alias sentinel="ssh ubuntu@sentinel.lan"
|
|
alias reddish="ssh pratham@reddish.lan"
|
|
alias rustyvm="ssh pratham@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 tmux="/usr/bin/tmux -f $HOME/.config/tmux/tmux.conf"
|
|
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 [[ "$MACHINE_HOSTNAME" == "flameboi" || "$MACHINE_HOSTNAME" == "vasudev" || "$MACHINE_HOSTNAME" == "rustyvm" ]]; then
|
|
alias suslock="$HOME/.config/polybar/mods/module_suspend_script.sh"
|
|
alias drivetemp="sudo hdparm -CH /dev/sda /dev/sdb /dev/sdc /dev/sdd"
|
|
alias paru="LESS=SRX paru"
|
|
|
|
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 -Qdt | choose 0)"
|
|
|
|
# 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="sudo 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
|
|
}
|
|
|
|
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
|
|
|
|
# aliases for ls
|
|
alias l="/usr/local/bin/gls --group-directories-first --color=auto -v"
|
|
alias ll="/usr/local/bin/gls --group-directories-first --color=auto -1lv"
|
|
alias la="/usr/local/bin/gls --group-directories-first --color=auto -1Av"
|
|
alias lo="/usr/local/bin/gls --group-directories-first --color=auto -1v"
|
|
alias llh="/usr/local/bin/gls --group-directories-first --color=auto -1hlv"
|
|
alias lah="/usr/local/bin/gls --group-directories-first --color=auto -1Ahlv"
|
|
alias ldt="/usr/local/bin/gls --group-directories-first --color=auto -1Altv"
|
|
|
|
# aliases for grep
|
|
alias grep="/usr/local/bin/ggrep --color=auto"
|
|
alias greplv="/usr/local/bin/ggrep --color=auto -lv"
|
|
alias grepli="/usr/local/bin/ggrep --color=auto -li"
|
|
alias grepv="/usr/local/bin/ggrep --color=auto -v"
|
|
alias grepi="/usr/local/bin/ggrep --color=auto -i"
|
|
|
|
# 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
|