# shellcheck shell=bash # shellcheck disable=SC1090,SC1091,SC2034 # Set aliases hash ug 2>/dev/null && alias grep="ugrep" hash bat 2>/dev/null && alias cat="bat -p" hash zoxide 2>/dev/null && alias cd="z" hash fd 2>/dev/null && alias find="fd" hash numbat 2>/dev/null && alias bc="numbat" # numbat is a bit more than just a bc alternative # hash eva 2>/dev/null && alias bc="eva" # eva is a bc alternative, but don't want to switch yet hash fend 2>/dev/null && alias units="fend" # fend's syntax is a bit different from units, don't want to switch yet # hash sd 2>/dev/null && alias sed="sd" # Disabled because some scripts use sed, and don't set the -i flag hash dust 2>/dev/null && alias du="dust" hash erd 2>/dev/null && alias tree="erd" hash dua 2>/dev/null && alias duai="dua interactive" hash tealdeer 2>/dev/null && alias tldr="tealdeer" hash hexyl 2>/dev/null && alias xxd="hexyl" hash xdg-open 2>/dev/null && alias start="xdg-open" && alias open="xdg-open" hash micro 2>/dev/null && alias edit="micro" && alias nano="micro" hash nvim 2>/dev/null && alias vim="nvim" && alias vi="nvim" hash trash-put 2>/dev/null && alias rm="trash-put" && alias tp="trash-put" hash gallery-dl 2>/dev/null && alias gallery-dl="gallery-dl --cookies-from-browser firefox" if hash lsb_release 2>/dev/null; then if [[ $(lsb_release -si) =~ "Arch" ]]; then alias update-mirrors="rate-mirrors arch | sudo tee /etc/pacman.d/mirrorlist; rate-mirrors chaotic-aur | sudo tee /etc/pacman.d/chaotic-mirrorlist" # System package managers hash pacman 2>/dev/null && command="sudo pacman -Syu; sudo pacman -Sc; " hash pamac 2>/dev/null && command="pamac update; pamac clean; " hash yay 2>/dev/null && command="yay; yay -Sc; " hash paru 2>/dev/null && command="paru; paru -c; " elif [[ $(lsb_release -si) =~ "Debian" || $(lsb_release -si) =~ "Ubuntu" ]]; then alias update-mirrors="sudo nala fetch --auto -c US -c CA" # System package managers hash apt 2>/dev/null && command="sudo apt update && sudo apt upgrade && sudo apt autoremove; " hash aptitude 2>/dev/null && command="sudo aptitude update && sudo aptitude upgrade && sudo aptitude autoremove; " hash nala 2>/dev/null && command="sudo nala update && sudo nala upgrade && sudo nala autoremove; " fi # Non system packages hash flatpak 2>/dev/null && command+="flatpak update && flatpak uninstall --unused; " hash snap 2>/dev/null && command+="sudo snap refresh && sudo snap remove --purge $(snap list --all | awk '/^.*disabled/{print $1}'); " # Firmware hash fwupdmgr 2>/dev/null && command+="fwupdmgr refresh --force && fwupdmgr update;" # We want this to be expanded to the command, as the command is not very helpful # shellcheck disable=SC2139 alias update="$command" elif [[ "$TERMUX_VERSION" ]]; then # Termux, special case alias update-mirrors="termux-change-repo" alias update="pkg upgrade && pkg autoclean" # Non privaledged environemnt, have to use local package managers like eget, nix, etc else alias update-mirrors="echo 'No mirrors to update'" alias update='eget -D; . "$HOME"/.config/eget/post_install.sh' alias nix-shell-local="nix-user-chroot ~/.local/share/nix bash" if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then . ~/.nix-profile/etc/profile.d/nix.sh fi fi if hash eza 2>/dev/null; then function ls { if [[ "$*" =~ "-a" || "$*" =~ "-A" || "$*" =~ "--all" || "$*" =~ "--almost-all" ]]; then eza --icons --long "$@" else eza --icons --long --ignore-glob "$([[ -f .hidden ]] && < .hidden tr '\n' '|')" "$@" fi } fi if hash sigtool 2>/dev/null; then # clamav-exception-add # Adds a file to the clamav user-defined exceptions list # Usage: clamav-exception-add # Example: clamav-exception-add /path/to/file # Note: This requires root privileges, so you may need to run it with sudo function clamav-exception-add { if [[ -z $1 ]]; then echo "Usage: clamav-exception-add " return 1 fi if [[ ! -f $1 ]]; then echo "File not found: $1" return 1 fi sudo bash -c "sigtool --sha256 $1 >> /var/lib/clamav/user-defined-exceptions.sfp" } fi # Dotfiles management # TODO: Rewrite to use bash read instead of zsh read if hash chezmoi 2>/dev/null; then function .add { if [[ -z $1 || -z $2 ]]; then echo "Usage: .add " return 1 fi chezmoi add "$1" chezmoi git add . chezmoi git status echo -n "Commit changes? [y/N] " read -r answer if [[ $answer =~ ^[Yy]$ ]]; then chezmoi git -- commit -m "$2" echo -n "Push changes? [y/N] " read -r answer if [[ $answer =~ ^[Yy]$ ]]; then chezmoi git push fi fi } # TODO: Rewrite to use bash read instead of zsh read function .re-add { if [[ -z $1 ]]; then echo "Usage: .re-add " return 1 fi chezmoi re-add chezmoi git status chezmoi git diff echo -n "Commit changes? [y/N] " read -r answer if [[ $answer =~ ^[Yy]$ ]]; then chezmoi git -- commit -am "$1" echo -n "Push changes? [y/N] " read -r answer if [[ $answer =~ ^[Yy]$ ]]; then chezmoi git push fi fi } alias .push="chezmoi git push" alias .pull="chezmoi git pull" alias .status="chezmoi git status" alias .diff="chezmoi git diff" alias .update="chezmoi update" fi # Other aliases alias rce='xdg-open $HOME/.bashrc && xdg-open $HOME/.zshrc && xdg-open $XDG_CONFIG_HOME/bash/.bash_aliases' alias ftpd-simple='python -m pyftpdlib' # XDG aliases alias wget='wget --hsts-file="$XDG_DATA_HOME"/wget-hsts' alias yarn='yarn --use-yarnrc "$XDG_CONFIG_HOME"/yarn/config' alias units='units --history "$XDG_DATA_HOME"/units_history' alias nvidia-settings='nvidia-settings --config="$XDG_CONFIG_HOME"/nvidia/settings' alias adb='HOME="$XDG_DATA_HOME"/android adb' # If we have local rust installed, set it up if [[ -f $XDG_DATA_HOME/cargo/env ]]; then . "$XDG_DATA_HOME/cargo/env" fi