Files
Dotfiles/roles/bash/files/.bashrc
2024-06-02 18:53:52 +02:00

68 lines
1.8 KiB
Bash

# 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 ya() {
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"
}
## Aliases
# Replace ls with eza
alias ls='eza -al --color=always --group-directories-first' # preferred listing
alias la='eza -a --color=always --group-directories-first' # all files and dirs
alias ll='eza -l --color=always --group-directories-first' # long format
alias lt='eza -aT --color=always --group-directories-first' # tree listing
alias l.='eza -ald --color=always --group-directories-first .*' # show only dotfiles
# Replace cat with bat
if [ -f /usr/bin/bat ]; then
alias cat='bat --style header --style snip --style changes --style header'
fi
# Replace yay with paru
if [ -f /usr/bin/paru ]; then
alias yay='paru'
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 rip="expac --timefmt='%Y-%m-%d %T' '%l\t%n %v' | sort | tail -200 | nl"