# If not running interactively, don't do anything [[ $- != *i* ]] && return # Env vars export EDITOR=nvim export VISUAL=nvim # Load starship prompt if starship is installed if [ -f /usr/bin/starship ]; then eval "$(starship init bash)" fi ## Functions # Yazi function y() { local tmp="$(mktemp -t "yazi-cwd.XXXXX")" yazi "$@" --cwd-file="$tmp" if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then cd -- "$cwd" fi rm -f -- "$tmp" } # Chezmoi apply changes from current chezmoi DIR function ca() { chezmoi apply "$(chezmoi target-path "${1:-.}")" } isbusy() { local path="${1:-}" if [ -z "$path" ]; then echo "Usage: isbusy " >&2 return 1 fi if ! path="$(realpath -e -- "$path" 2>/dev/null)"; then echo "isbusy: cannot resolve '$1'" >&2 return 1 fi sudo lsof +f -- "$path" } ## Aliases # Replace ls with eza if [ -f /usr/bin/eza ]; then alias ls='eza -al --color=always --group-directories-first --icons=auto' # preferred listing alias la='eza -a --color=always --group-directories-first --icons=auto' # all files and dirs alias ll='eza -l --color=always --group-directories-first --icons=auto' # long format alias lt='eza -aT --color=always --group-directories-first --icons=auto' # tree listing alias l.='eza -ald --color=always --group-directories-first --icons=auto .*' # show only dotfiles fi # Replace cat with bat if [ -f /usr/bin/bat ]; then alias cat='bat --style header --style snip --style changes --style header' fi # Replace paru with yay if [ -f /usr/bin/yay ]; then alias paru='yay' fi # Aliases alias :q='exit' alias cls='clear' alias dir='dir --color=auto' alias grepe='grep -E --color=auto' alias grepf='grep -F --color=auto' alias grepi='grep -i --color=auto' alias fixpacman="sudo rm /var/lib/pacman/db.lck" alias grep='grep --color=auto' alias grubup="sudo update-grub" alias hw='hwinfo --short' alias psmem10='ps auxf | sort -nr -k 4 | head -10' alias psmem='ps auxf | sort -nr -k 4' alias rmpkg="sudo pacman -Rdd" alias tarnow='tar -acf ' alias untar='tar -zxvf ' alias wget='wget -c ' # Cleanup orphaned packages alias cleanup='sudo pacman -Rns `pacman -Qtdq`' # Get the error messages from journalctl alias jctl="journalctl -p 3 -xb" # Recent installed packages alias ripp="expac --timefmt='%Y-%m-%d %T' '%l\t%n %v' | sort | tail -200 | nl" if [ -f /usr/bin/fastfetch ]; then fastfetch fi