254 lines
11 KiB
Plaintext
254 lines
11 KiB
Plaintext
export TIMEFMT=$'\nJob\t%J\n\nCPU\t%P\nuser\t%U\nsystem\t%S\ntotal\t%E'
|
|
# add dir to PATH if present
|
|
# precedence from top (lowest) to bottom (highest)
|
|
[[ -d "$HOME/.local/bin" ]] && export PATH=$HOME/.local/bin:$PATH
|
|
[[ -d "$HOME/.cargo/bin" ]] && export PATH=$HOME/.cargo/bin:$PATH
|
|
[[ -d /usr/local/sbin ]] && export PATH=/usr/local/sbin:$PATH
|
|
[[ -d /usr/sbin ]] && export PATH=/usr/sbin:$PATH
|
|
[[ -d /sbin ]] && export PATH=/sbin:$PATH
|
|
[[ -d /usr/local/bin ]] && export PATH=/usr/local/bin:$PATH
|
|
[[ -d /usr/bin ]] && export PATH=/usr/bin:$PATH
|
|
[[ -d /bin ]] && export PATH=/bin:$PATH
|
|
[[ -d "$HOME/.local/bin" ]] && export PATH=$HOME/.local/bin:$PATH
|
|
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
|
|
# :(
|
|
fi
|
|
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" # ~/.zshrc will automatically source ~/.zsh_aliases
|
|
alias custcp="rsync --verbose --recursive --size-only --human-readable --progress --stats --itemize-changes"
|
|
alias pysort="$HOME/.scripts/other/sort.py"
|
|
alias download="aria2c -x 16 -k 1M --file-allocation=none --continue=false"
|
|
alias vim="nvim"
|
|
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"
|
|
|
|
if command -v batcat > /dev/null; then
|
|
alias bat="batcat"
|
|
fi
|
|
|
|
alias sudo="sudo "
|
|
if command -v doas > /dev/null; then
|
|
unalias sudo
|
|
alias sudo="doas "
|
|
fi
|
|
|
|
# some common functions
|
|
towebp() {
|
|
cwebp -q 80 "$1" -o "$1".webp
|
|
}
|
|
|
|
togif() {
|
|
ffmpeg -i "$1" -pix_fmt rgb24 "$1".gif
|
|
}
|
|
|
|
gitaddpush() {
|
|
git ls-remote --quiet --exit-code origin >/dev/null 2>&1
|
|
if [[ $? -ne 0 ]]; then
|
|
git remote add origin "$1"
|
|
fi
|
|
git remote set-url --add --push origin "$1"
|
|
}
|
|
|
|
gitaddpull() {
|
|
git ls-remote --quiet --exit-code origin >/dev/null 2>&1
|
|
if [[ $? -ne 0 ]]; then
|
|
git remote add origin "$1"
|
|
fi
|
|
git remote set-url --add --pull origin "$1"
|
|
}
|
|
|
|
|
|
# Linux specific things
|
|
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|
|
|
# make less more friendly for non-text input files, see lesspipe(1)
|
|
[[ -x /usr/bin/lesspipe ]] && eval "$(SHELL=/bin/sh lesspipe)"
|
|
|
|
export EDITOR=/usr/bin/nvim
|
|
export SYSTEMD_EDITOR=/usr/bin/nvim
|
|
|
|
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"
|
|
|
|
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"
|
|
|
|
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"
|
|
|
|
source /etc/os-release
|
|
MACHINE_HOSTNAME=$(cat /etc/hostname)
|
|
|
|
if [[ "$NAME" == "Pop\!_OS" && "$MACHINE_HOSTNAME" == "flameboi" ]]; then
|
|
|
|
export OWNDIR=/heathen_disk
|
|
|
|
alias sentinel="ssh ubuntu@sentinel.lan"
|
|
alias bluefeds="ssh pratham@bluefeds.lan"
|
|
|
|
alias flatpakupdates="flatpak remote-ls --updates flathub"
|
|
alias mpv="/usr/bin/mpv --geometry=60% --vo=gpu --hwdec=vaapi"
|
|
alias pbcopy="xsel --clipboard --input"
|
|
alias drivetemp="sudo hdparm -CH /dev/sda /dev/sdb /dev/sdc /dev/sdd"
|
|
|
|
|
|
# window manager
|
|
alias suslock="$HOME/.config/polybar/mods/module_suspend_script.sh"
|
|
alias gnomecontrolcenter="XDG_CURRENT_DESKTOP=GNOME gnome-control-center"
|
|
alias gnomecc="XDG_CURRENT_DESKTOP=GNOME gnome-control-center"
|
|
|
|
|
|
if command -v flatpak > /dev/null; then
|
|
|
|
# Get a list of flatpak applications in the reverse domain name format
|
|
readarray -t ids < <(flatpak list --app --columns=application)
|
|
for id in "${ids[@]}"; do
|
|
# Take everything past the last dot (the name)
|
|
name="${id##*.}"
|
|
# Make it lowercase to approximate binary name
|
|
binary="${name,,}"
|
|
|
|
# If there is not already a command at that name
|
|
if ! command -v "${binary}" > /dev/null; then
|
|
# Create an alias that runs the flatpak
|
|
alias "$binary=flatpak run \"$id\""
|
|
fi
|
|
done
|
|
fi
|
|
|
|
owndisk() {
|
|
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 [[ "$NAME" == "Fedora Linux" && "$MACHINE_HOSTNAME" == "bluefeds" ]]; then
|
|
alias sentinel="ssh ubuntu@sentinel.lan"
|
|
alias clear="/usr/bin/clear && printf '\e[3J'"
|
|
alias confont="setfont /usr/share/consolefonts/Lat2-Terminus28x14.psf.gz"
|
|
alias drivetemp="sudo hdparm -CH /dev/sda /dev/sdb /dev/sdc /dev/sdd"
|
|
alias containerupdate='podman auto-update --dry-run --format="{{.Unit}}\t{{.Updated}}"'
|
|
alias containerfreeall="podman system prune -a"
|
|
alias containerdisableall="systemctl --user disable container-gitea-chitragupta container-hugo-vaikunthnatham container-nextcloud-chitragupta container-hugo-mahayogi container-gitea-govinda container-nextcloud-govinda container-caddy-vishwambhar"
|
|
alias containerenableall="systemctl --user enable container-gitea-chitragupta container-hugo-vaikunthnatham container-nextcloud-chitragupta container-hugo-mahayogi container-gitea-govinda container-nextcloud-govinda container-caddy-vishwambhar"
|
|
|
|
containerstopall() {
|
|
ALL_CONTAINERS=(
|
|
"container-caddy-vishwambhar.service" \
|
|
"container-nextcloud-govinda.service" \
|
|
"container-gitea-govinda.service" \
|
|
"container-nextcloud-chitragupta.service" \
|
|
"container-gitea-chitragupta.service" \
|
|
"container-hugo-vaikunthnatham.service" \
|
|
"container-hugo-mahayogi.service" \
|
|
)
|
|
|
|
for INDV_SERVICE in ${ALL_CONTAINERS[@]}; do
|
|
CHECK_ENABLEMENT=$(systemctl --user is-enabled "${INDV_SERVICE}")
|
|
STAT_CMP="enabled"
|
|
|
|
# check if a service is NOT enabled
|
|
if [[ "$CHECK_ENABLEMENT" != "$STAT_CMP" ]]; then
|
|
systemctl --user is-active --quiet service "${INDV_SERVICE}" && systemctl --user stop "${INDV_SERVICE}" && echo "${INDV_SERVICE}: stopped"
|
|
fi
|
|
done
|
|
}
|
|
|
|
containerstats() {
|
|
systemctl --user status \
|
|
container-gitea-chitragupta \
|
|
container-hugo-vaikunthnatham \
|
|
container-nextcloud-chitragupta \
|
|
container-hugo-mahayogi \
|
|
container-gitea-govinda \
|
|
container-nextcloud-govinda \
|
|
container-transmission-raadhe \
|
|
container-caddy-vishwambhar | 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}/8"
|
|
echo -e "Containers:\t${TOTAL_CONTAINERS}/8"
|
|
}
|
|
|
|
rebuildzfs() {
|
|
ALL_KERNELS=($(sudo dnf info kernel | grep Source | awk '{print $3}' | sed "s/kernel-//g" | sed "s/src.rpm/$(uname -m)/g"))
|
|
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 KERN in ${ALL_KERNELS[@]}; do
|
|
ZFS_DKMS_STATUS=$(sudo dkms status -k ${KERN})
|
|
|
|
if [[ ${ZFS_DKMS_STATUS} =~ "zfs" ]]; then
|
|
echo -ne "ZFS is installed for ${KERN}, you may REINSTALL it using the following command:\nsudo dkms install ${LATEST_ZFS_VER} -k ${KERN}\n\n"
|
|
else
|
|
sudo dkms install ${LATEST_ZFS_VER} -k ${KERN}
|
|
echo -ne "\n--------------------------------------------------------------------------------\n"
|
|
fi
|
|
done
|
|
}
|
|
|
|
|
|
elif [[ "$NAME" == "Ubuntu" && "$MACHINE_HOSTNAME" == "sentinel" ]]; then
|
|
alias drivetemp="sudo hdparm -CH /dev/sda /dev/sdb /dev/sdc /dev/sdd"
|
|
|
|
elif [[ "$NAME" == "Arch Linux" && "$MACHINE_HOSTNAME" == "flameboi" ]]; then
|
|
export LESS=SRX
|
|
|
|
alias pkgupdateall="yay -Syu"
|
|
alias pkgshowfiles="pacman --query --list"
|
|
fi
|
|
|
|
elif [[ "$OSTYPE" == "darwin"* ]];then
|
|
|
|
export EDITOR=/usr/local/bin/nvim
|
|
[[ -d "/usr/local/sbin" ]] && export PATH=/usr/local/sbin:$PATH
|
|
typeset -U PATH
|
|
|
|
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"
|
|
|
|
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"
|
|
|
|
alias xargs="/usr/local/opt/findutils/libexec/gnubin/xargs"
|
|
|
|
alias flameboi="ssh pratham@flameboi.lan"
|
|
alias sentinel="ssh ubuntu@sentinel.lan"
|
|
alias bluefeds="ssh pratham@bluefeds.lan"
|
|
|
|
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
|