97 lines
2.1 KiB
Bash
97 lines
2.1 KiB
Bash
# Source other files
|
|
[ -r ~/.prompt ] && . ~/.prompt
|
|
[ -r ~/.devspec ] && . ~/.devspec
|
|
[ -r ~/.config/isotope.dark ] && . ~/.config/isotope.dark
|
|
|
|
# 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 clear="printf '\033c'" # faster than ncurses clear by a lot
|
|
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 $($PASTE_COMMAND)'
|
|
alias lc='fc -nl $HISTCMD'
|
|
|
|
# Completions for elevation program (https://codeberg.org/Bowuigi/Unit21 in management/boas)
|
|
complete -cf boas
|
|
|
|
# Random string (passwords)
|
|
randstr() {
|
|
tr -cd [:graph:] </dev/urandom | read -r -n 256 RAND
|
|
echo "$RAND"
|
|
}
|
|
|
|
# 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 "$UPDATE"; }
|
|
|
|
# Im too lazy to type
|
|
copy() {
|
|
printf "%s" "$(</dev/stdin)" > >($COPY_COMMAND)
|
|
}
|
|
|
|
# Get local IP
|
|
lip() {
|
|
local OLD_IFS="$IFS"
|
|
local LINE_NUM=0
|
|
local STR_NUM=0
|
|
while read -r LINE; do
|
|
if [[ "$LINE" == *"${1:-$WIFI}"* ]]; then
|
|
LINE_NUM=$((LINE_NUM+1))
|
|
if [[ $LINE_NUM == 2 ]]; then
|
|
for STR in $LINE; do
|
|
STR_NUM=$((STR_NUM+1))
|
|
if [[ $STR_NUM == 2 ]]; then
|
|
local IP="$STR"
|
|
IFS="/"
|
|
for STR in $IP; do
|
|
echo "$STR"
|
|
break 3
|
|
done
|
|
fi
|
|
done
|
|
fi
|
|
fi
|
|
done <<< "$(ip a)"
|
|
IFS="$OLD_IFS"
|
|
}
|
|
|
|
# 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 ~/{} {} 2> /dev/null \;; }
|
|
|
|
fixdh() { diffhome | awk '{print $2 " " $4}' | while read -r line; do cp $line; done; }
|