.files/.bashrc

70 lines
1.6 KiB
Bash

# Source prompt
. ~/.prompt
# History stuff
export HISTCONTROL=ignoredups:erasedups
export HISTFILESIZE=1000
export HISTSIZE=1000
export GPG_TTY=$(tty)
# We hate sudo here
alias sudo='sh -c "exit 1"'
# Other aliases
alias c='clear'
alias ls='ls --color=auto -FAh'
alias ll='ls -l'
alias rebash='. ~/.bashrc'
alias bashrc="$EDITOR ~/.bashrc && rebash"
alias nf='neofetch'
alias sshd='boas /usr/sbin/sshd'
alias ga='git add'
alias gc='git commit -sS'
alias gp='git push'
alias wv='mpv $(wl-paste)'
# Completions for elevation program (https://codeberg.org/Bowuigi/Unit21 in management/boas)
complete -cf boas
# Random string (passwords)
randstr() { tr -cd [:graph:] </dev/urandom | head -c${1:-256}; }
# Get CPU usage
cpusage() {
bc<<<"scale=3;$(ps aux | awk 'BEGIN {sum=0} {sum+=$3}; END {print sum}') / $(nproc --all)"
}
# Update and upgrade system
update() { boas sh -c 'apk update && apk upgrade -aiv && apk fix'; }
# Im too lazy to type
copy() {
tee >(wl-copy)
}
# Source colors for tty
. ~/.config/sxmo/isotope.dark
# Get local IP
lip() { ip a | grep ${1:-wlan0} | sed 1d | cut -d' ' -f6 | cut -d/ -f1; }
# URL-encode stdin
urlencode() {
LC_COLLATE_OLD=$LC_COLLATE
LC_COLLATE=C
local TEXT="$(</dev/stdin)"
local LENGTH="${#TEXT}"
for (( i = 0; i < LENGTH; i++ )); do
local c="${TEXT:$i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf '%s' "$c" ;;
*) printf '%%%02X' "'$c" ;;
esac
done
LC_COLLATE=$LC_COLLATE_OLD
}
diffhome() { find . -type f -regex '\./\.[^g].*' -exec diff -q ~/{} {} \;; }
fixdh() { find . -type f -regex '\./\.[^g].*' -exec diff -q ~/{} {} \; | awk '{print $2 " " $4}' | while read -r line; do cp $line; done; }