2022-04-26 02:38:06 +00:00
|
|
|
# Source other files
|
|
|
|
[ -r ~/.prompt ] && . ~/.prompt
|
2022-04-24 18:49:55 +00:00
|
|
|
[ -r ~/.devspec ] && . ~/.devspec
|
2022-04-26 02:38:06 +00:00
|
|
|
[ -r ~/.config/isotope.dark ] && . ~/.config/isotope.dark
|
2022-03-01 17:32:57 +00:00
|
|
|
|
2022-08-29 19:19:07 +00:00
|
|
|
[ -z "$EDITOR" ] && . ~/.profile
|
2022-09-12 11:49:05 +00:00
|
|
|
[ "$TERM" == "screen.linux" ] && export TERM="screen"
|
2022-08-29 19:19:07 +00:00
|
|
|
|
2022-03-02 15:58:27 +00:00
|
|
|
# History stuff
|
|
|
|
export HISTCONTROL=ignoredups:erasedups
|
|
|
|
export HISTFILESIZE=1000
|
|
|
|
export HISTSIZE=1000
|
|
|
|
|
2022-03-10 19:52:04 +00:00
|
|
|
export GPG_TTY=$(tty)
|
2022-03-02 15:58:27 +00:00
|
|
|
# We hate sudo here
|
2022-03-01 17:32:57 +00:00
|
|
|
alias sudo='sh -c "exit 1"'
|
2022-03-02 15:58:27 +00:00
|
|
|
# Other aliases
|
2022-05-01 02:04:04 +00:00
|
|
|
alias clear="printf '\033c'" # faster than ncurses clear by a lot
|
2022-03-01 17:32:57 +00:00
|
|
|
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'
|
2022-03-03 07:12:25 +00:00
|
|
|
alias ga='git add'
|
2022-03-10 04:58:43 +00:00
|
|
|
alias gc='git commit -sS'
|
2022-03-03 07:12:25 +00:00
|
|
|
alias gp='git push'
|
2022-04-24 18:49:55 +00:00
|
|
|
alias wv='mpv $($PASTE_COMMAND)'
|
2022-08-29 19:19:07 +00:00
|
|
|
alias lc='fc -nl $HISTCMD | xargs'
|
2022-08-11 02:45:07 +00:00
|
|
|
alias curl='curl -L'
|
2022-08-29 19:19:07 +00:00
|
|
|
alias prof='profanity'
|
2022-03-02 15:58:27 +00:00
|
|
|
|
|
|
|
# Completions for elevation program (https://codeberg.org/Bowuigi/Unit21 in management/boas)
|
|
|
|
complete -cf boas
|
|
|
|
|
|
|
|
# Random string (passwords)
|
2022-05-01 02:04:04 +00:00
|
|
|
randstr() {
|
2022-05-10 07:30:06 +00:00
|
|
|
tr -cd '[:graph:]' </dev/urandom | head -c ${1:-256}
|
2022-05-01 02:04:04 +00:00
|
|
|
}
|
2022-03-02 15:58:27 +00:00
|
|
|
|
|
|
|
# Get CPU usage
|
2022-03-01 17:32:57 +00:00
|
|
|
cpusage() {
|
|
|
|
bc<<<"scale=3;$(ps aux | awk 'BEGIN {sum=0} {sum+=$3}; END {print sum}') / $(nproc --all)"
|
|
|
|
}
|
|
|
|
|
2022-03-02 15:58:27 +00:00
|
|
|
# Update and upgrade system
|
2022-04-24 18:49:55 +00:00
|
|
|
update() { boas sh -c "$UPDATE"; }
|
2022-03-01 17:32:57 +00:00
|
|
|
|
2022-03-02 15:58:27 +00:00
|
|
|
# Im too lazy to type
|
2022-03-01 17:32:57 +00:00
|
|
|
copy() {
|
2022-05-01 02:04:04 +00:00
|
|
|
printf "%s" "$(</dev/stdin)" > >($COPY_COMMAND)
|
2022-03-01 17:32:57 +00:00
|
|
|
}
|
|
|
|
|
2022-03-02 15:58:27 +00:00
|
|
|
# URL-encode stdin
|
2022-03-01 17:32:57 +00:00
|
|
|
urlencode() {
|
2022-03-02 15:58:27 +00:00
|
|
|
LC_COLLATE_OLD=$LC_COLLATE
|
2022-03-01 17:32:57 +00:00
|
|
|
LC_COLLATE=C
|
|
|
|
|
|
|
|
local TEXT="$(</dev/stdin)"
|
|
|
|
local LENGTH="${#TEXT}"
|
|
|
|
for (( i = 0; i < LENGTH; i++ )); do
|
|
|
|
local c="${TEXT:$i:1}"
|
2022-05-18 03:32:04 +00:00
|
|
|
case $c in
|
2022-03-01 17:32:57 +00:00
|
|
|
[a-zA-Z0-9.~_-]) printf '%s' "$c" ;;
|
|
|
|
*) printf '%%%02X' "'$c" ;;
|
|
|
|
esac
|
|
|
|
done
|
2022-03-02 15:58:27 +00:00
|
|
|
LC_COLLATE=$LC_COLLATE_OLD
|
2022-03-01 17:32:57 +00:00
|
|
|
}
|
2022-03-03 16:54:48 +00:00
|
|
|
|
2022-04-24 18:49:55 +00:00
|
|
|
diffhome() { find . -type f -regex '\./\.[^g].*' -exec diff -q ~/{} {} 2> /dev/null \;; }
|
2022-03-03 16:54:48 +00:00
|
|
|
|
2022-05-18 03:32:04 +00:00
|
|
|
fixdh() {
|
|
|
|
diffhome | while read -r _ SRC _ DEST _; do
|
|
|
|
cp $SRC $DEST;
|
|
|
|
done;
|
|
|
|
}
|
2022-08-11 02:45:07 +00:00
|
|
|
|
|
|
|
strlen() {
|
|
|
|
N=$(wc -c <<< "$*")
|
|
|
|
((N--))
|
|
|
|
printf '%u\n' "$N"
|
|
|
|
}
|
|
|
|
|
|
|
|
uppweb() {
|
|
|
|
pushd ~/git/cobra.vern.cc
|
|
|
|
local DIR="/home/cobra/git/cobra.vern.cc"
|
|
|
|
rsync -rtvzP --exclude ".git" --exclude ".gitignore" --exclude 'README.md' --exclude 'LICENSE' $DIR/* vern.cc:~/public_html/
|
|
|
|
popd
|
|
|
|
}
|
|
|
|
|
|
|
|
upvweb() {
|
|
|
|
pushd ~/git/website
|
|
|
|
rsync --rsh='ssh -p1813' -rtvzP --exclude '.git' --exclude 'LICENSE' /home/cobra/git/website/ root@vern.cc:/var/www/website
|
2022-09-12 11:49:05 +00:00
|
|
|
ssh vern chown -R www-data:www-data /var/www/website
|
2022-08-11 02:45:07 +00:00
|
|
|
popd
|
|
|
|
}
|
|
|
|
|
|
|
|
upvgem() {
|
|
|
|
pushd ~/git/gemini
|
|
|
|
rsync --rsh='ssh -p1813' -rtvzP --exclude '.git' --exclude 'LICENSE' /home/cobra/git/gemini/ root@vern.cc:/home/gemini/gemini/vern.cc
|
|
|
|
popd
|
|
|
|
}
|
|
|
|
|
|
|
|
pubdate() {
|
|
|
|
date +'%a, %d %b %Y %T %z'
|
|
|
|
}
|
2022-09-12 11:49:05 +00:00
|
|
|
|
|
|
|
caption() {
|
|
|
|
[ -z "$3" ] && {
|
|
|
|
echo "Usage: caption [input] [output] [text...]"
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
local FILE="$1"
|
|
|
|
local OUT="$2"
|
|
|
|
shift 2
|
|
|
|
local TEXT="$*"
|
|
|
|
local WIDTH="$(identify -format "%[w]" "$FILE")"
|
|
|
|
local HEIGHT="$(identify -format "%[h]" "$FILE")"
|
|
|
|
local FONT_SIZE="$(((HEIGHT+WIDTH)/20))"
|
|
|
|
convert -gravity north \( -size "${WIDTH}x" -pointsize "$FONT_SIZE" -font 'Liberation-Sans-Bold' caption:"$TEXT" -gravity Center -extent "${WIDTH}x" \) "$FILE" -append "$OUT"
|
|
|
|
}
|
|
|
|
|
|
|
|
subcipher() {
|
|
|
|
local COLOR PERM L1 line grep word
|
|
|
|
if [ $# -lt 3 ]; then
|
|
|
|
if [ $# -lt 2 ] || [[ "$1" != "0" && "$1" != "1" ]]; then
|
|
|
|
printf "Usage: [0|1] subcipher file [string...]\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
COLOR="$1"
|
|
|
|
shift
|
|
|
|
PERM="$1"
|
|
|
|
shift
|
|
|
|
[ -z "$*" ] && set -- "$(</dev/stdin)"
|
|
|
|
L1="$(head -1 "$PERM")"
|
|
|
|
while read -r line; do
|
|
|
|
tr "${L1^^}${L1}" "${line^^}${line}" <<< "$*"
|
|
|
|
done < "$PERM" | \
|
|
|
|
while read -r line; do
|
|
|
|
for word in $line; do
|
|
|
|
[ $COLOR -eq 1 ] && grep="$(grep --color=always -xF "$word" /etc/dictionaries-common/words)"
|
|
|
|
printf %s "${grep:-$word} "
|
|
|
|
done
|
|
|
|
printf '\n'
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
playcd() {
|
|
|
|
mpv --start=00:00:00.0000000 av://libcdio:/dev/cdrom --cache=yes
|
|
|
|
}
|
|
|
|
|
|
|
|
gpginfo() {
|
|
|
|
gpg --with-colons --import-options show-only --import
|
|
|
|
}
|
|
|
|
|
|
|
|
baseto() {
|
|
|
|
local i="$1"
|
|
|
|
local o="$2"
|
|
|
|
shift 2
|
|
|
|
bc <<< "obase=$o;$(($i#$*))"
|
|
|
|
}
|