Update after 400 years

Signed-off-by: Moxie "The Cobra" Widulski <cobra@vern.cc>
This commit is contained in:
Skylar "The Cobra" Widulski 2022-08-10 22:45:07 -04:00
parent 2736c6a371
commit 255ac30cff
Signed by: cobra
GPG Key ID: 4FD8F812083FF6F9
4 changed files with 106 additions and 78 deletions

50
.bashrc
View File

@ -25,6 +25,7 @@ alias gc='git commit -sS'
alias gp='git push'
alias wv='mpv $($PASTE_COMMAND)'
alias lc='fc -nl $HISTCMD'
alias curl='curl -L'
# Completions for elevation program (https://codeberg.org/Bowuigi/Unit21 in management/boas)
complete -cf boas
@ -47,26 +48,6 @@ copy() {
printf "%s" "$(</dev/stdin)" > >($COPY_COMMAND)
}
# Get local IP
lip() {
local OLD_IFS="$IFS"
local LINE_NUM=0
while read -r _ IP _; do
if [[ "$IP" == "${1:-$WIFI}": ]]; then
((LINE_NUM++))
if [[ $LINE_NUM == 2 ]]; then
IFS="/"
for STR in $IP; do
echo "$STR"
break 3
done
fi
fi
[[ $LINE_NUM -gt 0 ]] && ((LINE_NUM++))
done <<< "$(ip a)"
IFS="$OLD_IFS"
}
# URL-encode stdin
urlencode() {
LC_COLLATE_OLD=$LC_COLLATE
@ -91,3 +72,32 @@ fixdh() {
cp $SRC $DEST;
done;
}
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
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'
}

View File

@ -1 +1,4 @@
browser "mpv --user-agent=Mozilla/5.0 '--ytdl-format=bestvideo[height=?480][fps<=?30]+bestaudio/best' %u"
browser "mpv --user-agent=Mozilla/5.0 '--ytdl-format=bestvideo[height=?720][fps<=?30]+bestaudio/best' %u"
use-proxy yes
proxy-type socks5h
proxy 127.0.0.1:9050

View File

@ -1,3 +1,12 @@
export EDITOR=vim
export INVIDIOUS="https://invidious.snopyta.org"
export INVIDIOUS="https://inv.vern.cc"
export PATH="$HOME/.local/bin:$PATH"
export LESS_TERMCAP_mb=''
export LESS_TERMCAP_md=''
export LESS_TERMCAP_me=''
export LESS_TERMCAP_se=''
export LESS_TERMCAP_so=''
export LESS_TERMCAP_ue=''
export LESS_TERMCAP_us=''
export LESS=-R

118
.prompt
View File

@ -33,69 +33,69 @@ __get_cmd_time() {
local HOUR
local MINS
local SECS
((YEAR=10#0$(($(TZ=UTC printf '%(%Y)T' $CMD_TIME)))-1970))
((DAYS=10#0$(TZ=UTC printf '%(%j)T' $CMD_TIME)))
((HOUR=10#0$(TZ=UTC printf '%(%H)T' $CMD_TIME)))
((MINS=10#0$(TZ=UTC printf '%(%M)T' $CMD_TIME)))
((SECS=10#0$(TZ=UTC printf '%(%S)T' $CMD_TIME)))
((YEAR=10#$(($(TZ=UTC printf '%(%Y)T' "$CMD_TIME")))-1970))
((DAYS=10#$(TZ=UTC printf '%(%j)T' "$CMD_TIME")))
((HOUR=10#$(TZ=UTC printf '%(%H)T' "$CMD_TIME")))
((MINS=10#$(TZ=UTC printf '%(%M)T' "$CMD_TIME")))
((SECS=10#$(TZ=UTC printf '%(%S)T' "$CMD_TIME")))
# Choose whether or not to print hours minutes and seconds
[[ $CMD_TIME -ge 31536000 ]] && printf '%sy ' ${YEAR}
[[ $CMD_TIME -ge 86400 ]] && printf '%sd ' ${DAYS}
[[ $CMD_TIME -ge 3600 ]] && printf '%sh ' ${HOUR}
[[ $CMD_TIME -ge 60 ]] && printf '%sm ' ${MINS}
[[ $CMD_TIME -ge 1 ]] && printf '%ss ' ${SECS}
[[ $CMD_TIME -ge 31536000 ]] && printf '%sy ' "${YEAR}"
[[ $CMD_TIME -ge 86400 ]] && printf '%sd ' "${DAYS}"
[[ $CMD_TIME -ge 3600 ]] && printf '%sh ' "${HOUR}"
[[ $CMD_TIME -ge 60 ]] && printf '%sm ' "${MINS}"
[[ $CMD_TIME -ge 1 ]] && printf '%ss ' "${SECS}"
# If you want to have a limit uncomment the next line and replace somenum with
# the minimum microseconds
# [[ $CMD_US -ge somenum ]] &&
printf '%sμs' ${CMD_US:-0}
printf '%sμs' "${CMD_US:-0}"
}
__sig() {
# Giant switch case for getting the name of the signal (`kill -l`)
local ITR=0
local RET
for RET in $@; do
for RET in "$@"; do
if [[ $ITR != 0 ]]; then
printf '%s|%s' "$_WHT" "$_RED"
fi
((ITR++))
case $RET in
126): ACCES ;;
127): NOENT ;;
129): HUP ;;
130): INT ;;
131): QUIT ;;
132): ILL ;;
133): TRAP ;;
134): ABRT ;;
135): BUS ;;
136): FPE ;;
137): KILL ;;
138): USR1 ;;
139): SEGV ;;
140): USR2 ;;
141): PIPE ;;
142): ALRM ;;
143): TERM ;;
144): STKFLT ;;
145): CHLD ;;
146): CONT ;;
147): STOP ;;
148): TSTP ;;
149): TTIN ;;
150): TTOU ;;
151): URG ;;
152): XCPU ;;
153): XFSZ ;;
154): VTALRM ;;
155): PROF ;;
156): WINCH ;;
157): IO ;;
158): PWR ;;
159): SYS ;;
16[3-9]|1[7-8][0-9]|19[0-2]): RT$(($RET-128)) ;; # Savagery
*): $RET ;; # Print exit code if not in list
126): "ACCES" ;;
127): "NOENT" ;;
129): "HUP" ;;
130): "INT" ;;
131): "QUIT" ;;
132): "ILL" ;;
133): "TRAP" ;;
134): "ABRT" ;;
135): "BUS" ;;
136): "FPE" ;;
137): "KILL" ;;
138): "USR"1 ;;
139): "SEGV" ;;
140): "USR"2 ;;
141): "PIPE" ;;
142): "ALRM" ;;
143): "TERM" ;;
144): "STKFLT" ;;
145): "CHLD" ;;
146): "CONT" ;;
147): "STOP" ;;
148): "TSTP" ;;
149): "TTIN" ;;
150): "TTOU" ;;
151): "URG" ;;
152): "XCPU" ;;
153): "XFSZ" ;;
154): "VTALRM" ;;
155): "PROF" ;;
156): "WINCH" ;;
157): "IO" ;;
158): "PWR" ;;
159): "SYS" ;;
16[3-9]|1[7-8][0-9]|19[0-2]): "RT$((RET-128))" ;; # Savagery
*): "$RET" ;; # Print exit code if not in list
esac
printf '%s' "$_"
done
@ -115,7 +115,7 @@ __ssh() {
__prompt() {
# Get exit code (must be first)
local PLC=(${PIPESTATUS[@]})
local PLC=("${PIPESTATUS[@]}")
# Reset time when prompt was first displayed after command
# this contributes to the ~40 microsecond difference in $CMD_US and the actual time it took
@ -142,10 +142,16 @@ __prompt() {
((CMD_TIME=CMD_US/1000000))
[[ ${#CMD_US} -lt 6 ]] || CMD_US="${CMD_US: -6}"
((CMD_US=10#0$CMD_US))
((CMD_US=10#$CMD_US))
# Set prompt sections
local SIG
local COL
local UHD
local TIME
local IND
# Text
# ssh detection and indicator
@ -153,23 +159,23 @@ __prompt() {
# [INT], [4], etc.
local RET
for RET in ${PLC[@]}; do
if [[ $RET > 0 ]]; then
local SIG="$(printf '%s[%s%s%s] ' "$_BLU" "$_RED" "$(__sig ${PLC[@]})" "$_BLU")"
for RET in "${PLC[@]}"; do
if [[ $RET -gt 0 ]]; then
SIG="$(printf '%s[%s%s%s] ' "$_BLU" "$_RED" "$(__sig "${PLC[@]}")" "$_BLU")"
break
fi
done
# [user@homeserver:~]
local COL="$([[ $UID == 0 ]] && printf '%s' "$_RED" || printf '%s' "$_YLW")"
local UHD="${_BLD}${_BLU}[${COL}\u${_PRP}@${_CYN}\h${_PRP}:${_GRN}\w${_BLU}]"
COL="$([[ $UID == 0 ]] && printf '%s' "$_RED" || printf '%s' "$_YLW")"
UHD="${_BLD}${_BLU}[${COL}\u${_PRP}@${_CYN}\h${_PRP}:${_GRN}\w${_BLU}]"
# 2y 351d 12m 43s 382969μs
local TIME="${_YLW}$(__get_cmd_time)"
TIME="${_YLW}$(__get_cmd_time)"
# Random colored $ or #
_RAND256="\[\033[38;2;$((RANDOM%256));$((RANDOM%256));$((RANDOM%256))m\]"
local IND="${_RAND256}\\$"
IND="${_RAND256}\\$"
# Set the prompt
PS1="${_NON}${SSH}${SIG}${UHD} ${TIME} ${IND} ${_NON}"