soda: custom shell profile

This commit is contained in:
Max Headroom 2022-05-28 21:54:12 +02:00
parent bcf8a9ba96
commit 8d56f4aeb2
5 changed files with 208 additions and 0 deletions

View file

@ -0,0 +1,7 @@
{
environment.interactiveShellInit = ''
source ${./insults.sh}
source ${./motd.sh}
source ${./soda-prompt.sh}
'';
}

View file

@ -0,0 +1,136 @@
print_message () {
local messages
local message
messages=(
"Don't you know anything?"
"RTFM!"
"Haha, n00b!"
"Wow! That was impressively wrong!"
"Pathetic"
"The worst one today!"
"n00b alert!"
"Your application for reduced salary has been sent!"
"plz uninstall"
"And the Darwin Award goes to.... ${USER}!"
"ERROR_INCOMPETENT_USER"
"Incompetence is also a form of competence"
"Bad."
"Fake it till you make it!"
"What is this...? Amateur hour!?"
"Come on! You can do it!"
"Nice try."
"What if... you type an actual command the next time!"
"What if I told you... it is possible to type valid commands."
"Y u no speak computer???"
"This is not Windows"
"Perhaps you should leave the command line alone..."
"Please step away from the keyboard!"
"error code: 1D10T"
"ACHTUNG! ALLES TURISTEN UND NONTEKNISCHEN LOOKENPEEPERS! DAS KOMPUTERMASCHINE IST NICHT FÜR DER GEFINGERPOKEN UND MITTENGRABEN! ODERWISE IST EASY TO SCHNAPPEN DER SPRINGENWERK, BLOWENFUSEN UND POPPENCORKEN MIT SPITZENSPARKEN. IST NICHT FÜR GEWERKEN BEI DUMMKOPFEN. DER RUBBERNECKEN SIGHTSEEREN KEEPEN DAS COTTONPICKEN HÄNDER IN DAS POCKETS MUSS. ZO RELAXEN UND WATSCHEN DER BLINKENLICHTEN."
"Pro tip: type a valid command!"
"Go outside."
"This is not a search engine."
"(╯°□°)╯︵ ┻━┻"
"¯\_(ツ)_/¯"
"So, I'm just going to go ahead and run rm -rf / for you."
"Why are you so stupid?!"
"Perhaps computers is not for you..."
"Why are you doing this to me?!"
"Don't you have anything better to do?!"
"I am _seriously_ considering 'rm -rf /'-ing myself..."
"This is why you get to see your children only once a month."
"This is why nobody likes you."
"Are you even trying?!"
"Try using your brain the next time!"
"My keyboard is not a touch screen!"
"Commands, random gibberish, who cares!"
"Are you always this stupid or are you making a special effort today?!"
"Dropped on your head as a baby, eh?"
"Brains aren't everything. In your case they're nothing."
"I don't know what makes you so stupid, but it really works."
"You are not as bad as people say, you are much, much worse."
"Two wrongs don't make a right, take your parents as an example."
"You must have been born on a highway because that's where most accidents happen."
"If what you don't know can't hurt you, you're invulnerable."
"If ignorance is bliss, you must be the happiest person on earth."
"You're proof that god has a sense of humor."
"Keep trying, someday you'll do something intelligent!"
"If shit was music, you'd be an orchestra."
"How many times do I have to flush before you go away?"
)
# If CMD_NOT_FOUND_MSGS array is populated use those messages instead of the defaults
[[ -n ${CMD_NOT_FOUND_MSGS} ]] && messages=( "${CMD_NOT_FOUND_MSGS[@]}" )
# If CMD_NOT_FOUND_MSGS_APPEND array is populated append those to the existing messages
[[ -n ${CMD_NOT_FOUND_MSGS_APPEND} ]] && messages+=( "${CMD_NOT_FOUND_MSGS_APPEND[@]}" )
# Seed RANDOM with an integer of some length
RANDOM=$(od -vAn -N4 -tu < /dev/urandom)
# Print a randomly selected message, but only about 100% the time to annoy the user a
# little bit less.
if [[ $((${RANDOM} % 4)) -lt 4 ]]; then
message=${messages[${RANDOM} % ${#messages[@]}]}
printf "\n $(tput bold)$(tput setaf 1)${message}$(tput sgr0)\n\n" >&2
fi
}
function_exists () {
# Zsh returns 0 even on non existing functions with -F so use -f
declare -f $1 > /dev/null
return $?
}
#
# The idea below is to copy any existing handlers to another function
# name and insert the message in front of the old handler in the
# new handler. By default, neither bash or zsh has has a handler function
# defined, so the default behaviour is replicated.
#
# Also, ensure the handler is only copied once. If we do not ensure this
# the handler would add itself recursively if this file happens to be
# sourced multiple times in the same shell, resulting in a neverending
# stream of messages.
#
#
# Zsh
#
if function_exists command_not_found_handler; then
if ! function_exists orig_command_not_found_handler; then
eval "orig_$(declare -f command_not_found_handler)"
fi
else
orig_command_not_found_handler () {
printf "zsh: command not found: %s\n" "$1" >&2
return 127
}
fi
command_not_found_handler () {
print_message
orig_command_not_found_handler "$@"
}
#
# Bash
#
if function_exists command_not_found_handle; then
if ! function_exists orig_command_not_found_handle; then
eval "orig_$(declare -f command_not_found_handle)"
fi
else
orig_command_not_found_handle () {
printf "%s: %s: command not found\n" "$0" "$1" >&2
return 127
}
fi
command_not_found_handle () {
print_message
orig_command_not_found_handle "$@"
}

View file

@ -0,0 +1,54 @@
find -L /ascii -type f -print0 | shuf -zn1 | xargs -0 cat
bootup() {
tbold="$(tput bold)"
tpurple="$(tput setaf 5)"
tred_bold="$(tput bold; tput setaf 1)"
tblue="$(tput setaf 4)"
treset="$(tput sgr0)"
echo
#neofetch -L
source /etc/os-release
os_name=${PRETTY_NAME:-$NAME}
memory_usage=$(free -m | awk '/^Mem/ { printf "%sMB / %sMB\n", $3, $2}')
online_now=$(w -sh | wc -l)
server_time=$(date +'%A, %B %d, %T %z')
if [[ $online_now -gt 1 ]]; then
# Create a list of online users.
online_users=$(w -sh | awk '{print $1}' | uniq | tr "\n" " " | sed "s| |, |g;s|, $||g")
else
online_users="just you"
fi
printf "${tpurple}${tbold}soda${treset} ${tpurple}is currently using${treset} ${tbold}$os_name${treset} ${tpurple}as our OS${treset}
${tpurple}we are running on${treset} ${tbold}$memory_usage${treset} ${tpurple}of RAM${treset}
${tpurple}and we have${treset} ${tbold}$online_now${treset} ${tpurple}online user(s)!${treset} ($online_users)\n"
current_date=$(date +'%m-%d')
current_year=$(date +'%Y')
current_month="$(date +'%b')"
current_day="$(date +'%e' | sed 's|^\s||')"
soda_bday="04-10"
if [[ $current_day -ne 10 ]] && [[ $current_day -lt 10 ]] && [[ $current_month == "Apr" ]]; then
printf "\n${tred_bold}[!]${treset} btw it's ${tbold}$(( 10 - current_day ))${treset} day(s) (April 10th) till Soda's ${tbold}$(( current_year - 2019 ))${treset} year anniversary!\n"
fi
if [[ $current_date -eq $soda_bday ]]; then
printf "\n${tred_bold}HEY YOU!${treset} ${tblue}Today is the${treset} ${tbold}$(( current_year - 2019 ))${treset} ${tblue}year anniversary of Soda's creation!${treset} ${tbold}Happy Birthday Soda!${treset}\n"
sleep 3s
fi
printf "\n${tbold}Who's been around?${treset}\n"
last | sed -r "/(^$|^wtmp|^reboot)/d" | head -n 5
dickswing=$(last | sed -r "/^$/d;/^(wtmp|reboot)/d;/\(00:0[0-1]\)/d" | awk '{print $1}' | sort | uniq -c | sort -nr | sed -r "s/^\s+//")
as_of=$(last | grep "wtmp" | awk '{print "from", $4, $5, $7}')
echo -e "\n${tbold}Dickswing ($as_of to now):${treset}\n$dickswing"
echo -e "\033[0;31mNOTE\033[0m: must be logged in for more than 1 minute to be counted."
}
bootup

View file

@ -0,0 +1,7 @@
if [ -n "${BASH_VERSION-}" ]; then
if test $(id -u) -eq 0; then
PS1='\h # '
else
PS1='\h % '
fi
fi

View file

@ -1,4 +1,8 @@
{ {
imports = [
./shell-profile
];
environment.systemPackages = [ environment.systemPackages = [
# provide some editors # provide some editors
nano nano