Avatar
jascha
2479739594ed5802a96703e5a870b515d986982474a71feae180e8ecffa302c6
Run Relayable.org #nostr relay Bitcoin Class of 2009 🧡 Founder of @npub1tpy5sj0wc4txn8fdx02y7lrq33yxmwcrupfgw9jxzunmf9ypfhhs837gzc Cybersecurity pro with head in Clouds. By day I also build massively scalable and redundant data center/cloud architectures⚡🫂💜 9367 9961 90C9 B785 889D 276E A61B 8390 B08D CD40

Way too healthy. I drive way too fast to worry about cholesterol.

# Bash Aliases and Functions for Fun and Profit

Was thinking might he helpful to share some of my .bashrc aliases and functions. Please share any good ones you use in yours!

```

###### Tea timer

alias teatimer='$(STEEP=300; sleep $STEEP; xmessage "Your tea is done") &'

###### Reload bashrc fast

alias rl='. ~/.bashrc'

###### Extract a file without typing whole extension

extract () {

if [ -f $1 ] ; then

case $1 in

*.tar.bz2) tar xvjf $1 ;;

*.tar.gz) tar xvzf $1 ;;

*.bz2) bunzip2 $1 ;;

*.rar) unrar x $1 ;;

*.gz) gunzip $1 ;;

*.tar) tar xvf $1 ;;

*.tbz2) tar xvjf $1 ;;

*.tgz) tar xvzf $1 ;;

*.zip) unzip $1 ;;

*.Z) uncompress $1 ;;

*.7z) 7z x $1 ;;

*) echo "don't know how to extract '$1'..." ;;

esac

else

echo "'$1' is not a valid file!"

fi

}

###### Add an "alert" alias for long running commands. Use like so:

# sleep 10; alert

alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

###### Autocomplete ssh commands

complete -W "$(echo `cat ~/.bash_history | egrep '^ssh ' | sort | uniq | sed 's/^ssh //'`;)" ssh

###### shows list of repository keys

alias showkeys='sudo apt-key list'

##### show tcp/ip ports #####

alias ports='netstat -tulanp'

##### 5 pings will do #####

alias ping='ping -c 5'

###### find an unused unprivileged TCP port

function findtcp()

{

(netstat -atn | awk '{printf "%s\n%s\n", $4, $4}' | grep -oE '[0-9]*$'; seq 32768 61000) | sort -n | uniq -u | head -n 1

}

###### Geoip lookup (need geoip database: sudo apt-get install geoip-bin)

function geoip() {

geoiplookup $1

}

###### View the calender by typing the first three letters of the month.

alias jan='cal -m 01'

alias feb='cal -m 02'

alias mar='cal -m 03'

alias apr='cal -m 04'

alias may='cal -m 05'

alias jun='cal -m 06'

alias jul='cal -m 07'

alias aug='cal -m 08'

alias sep='cal -m 09'

alias oct='cal -m 10'

alias nov='cal -m 11'

alias dec='cal -m 12'

#### Large files fumction

function find_largest_files() {

du -h -x -s -- * | sort -r -h | head -20;

}

###### get IP address of a given interface

# Example: getip lo

# Example: getip eth0 # this is the default

function getip() { lynx -dump https://wtfismyip.com/text; }

##### list mounts in pretty column

alias mls='mount | column -t'

##### Show terminal history

alias h='history'

##### Oops forgot again

alias apt-get='sudo apt-get'

alias update='sudo apt-get update && sudo apt-get upgrade'

#======================================

#

# FUN STUFF

##=====================================

###### pretend to be busy in office to enjoy a cup of coffee

function grepcolor()

{

cat /dev/urandom | hexdump -C | grep --color=auto "ca fe"

}

###### a simple number guessing game

function hilow()

{

biggest=1000 # maximum number possible

guess=0 # guessed by player

guesses=0 # number of guesses made

number=$(( $$ % $biggest )) # random number, 1 .. $biggest

while [ $guess -ne $number ] ; do

echo -n "Guess? " ; read guess

if [ "$guess" -lt $number ] ; then

echo "... bigger!"

elif [ "$guess" -gt $number ] ; then

echo "... smaller!"

fi

guesses=$(( $guesses + 1 ))

done

echo "Right!! Guessed $number in $guesses guesses."

}

```

Back when government was decentralized.

Has anyone seen somewhat fake engagement bot behavior on here? Maybe I am just seeing things. 👾👀

Source code or it didn't happen. 🤣