/home/wpollock1/public_html/restricted/ShellScripting/dot.bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Turn on extended pattern matching:
shopt -s extglob
# Turns off "intelligent" Bash auto-completion (restores normal auto-completion):
# # complete -r
# Turns off '!' history expansion:
set +H
# Useful aliases:
alias awk='gawk --lint --re-interval' # Options for gawk
alias big='figlet -tcW -f banner'
alias ..='cd ..'
alias cd..='cd ..'
alias c11='gcc -std=c11 -Wall -Wextra -pedantic'
alias cls=clear
alias cr='chmod a+r'
alias cx='chmod a+x'
alias csc=gmcs # mono C# compiler
alias df='df -Th'
alias doh="play -q ~wpollock/sounds/Doh1.au"
alias du='du -h'
alias f=finger
alias gitk='gitk -a'
alias h='history 50'
alias l='ls -lh'
alias la='ls -aF'
alias li='ls -lhi'
alias ls='ls -F'
alias lsblk='lsblk -o NAME,GROUP,SIZE,MOUNTPOINT'
alias lslocks='lslocks -o +BLOCKER'
alias mail=nail
alias mc='echo ERROR with mc '
alias mess='tail -35 /var/log/messages'
alias myntpdate='ntpdate -q 0.us.pool.ntp.org'
alias nslookup='nslookup -sil'
alias nonascii='LC_ALL=C grep "[^[:print:]]"'
alias p7zip=7za
alias path='echo PATH=$PATH'
alias ping='ping -v'
alias pps='ps w -cfA'
alias ppwd=/bin/pwd
alias pri='cd ~/private'
alias quota='quota -vs'
alias rehash='hash -r'
alias rm='rm -i'
alias rrm='rm -rf'
#alias rs='set noglob; eval $(resize)'
alias su='LEVEL=0 su'
# Display shell variables, ignoring functions:
alias showenv="set |grep --color=never -E '^[[:alnum:]]+='"
alias showtemp="nc localhost 7634 | sed -e 's,|/dev/,\n&,g'; echo"
alias shell='{ ps -p $$ -o cmd=; :; } |sed -E "s/^-?([^ ]+).*/\1/"'
alias vi=vim
alias whereis='command -v'
alias cws='ssh wpollock@10.35.61.215'
alias yb='ssh wpollock@yborstudent.hccfl.edu'
alias ybsync='rsync -HavAXuz --include=/.bashrc --include=/.vim/*** --include=/.bash_profile --exclude=/.* --exclude=/tmp/*** --exclude=/private/journal --exclude=secret.txt yborstudent.hccfl.edu:./ --exclude=/mail/*** ~'
if test $(id -u) -eq 0
then
alias cp='cp -i'
alias mv='mv -i'
PCHAR='#'
else
PCHAR='$'
fi
# Define shell functions:
lsc() { /bin/ls -FC $* | more; }
#calc() { IFS= printf 'scale=4; %s\n' "$*" | bc -l; }
calc() { IFS= read -r -p 'Expression: ' EXPR;
printf 'scale=4; %s\n' "$EXPR" | bc -l;
}
ip2bin ()
{
NUMS=$(printf '%s\n' "$@" | sed -e 's/[^[:digit:]]/\n/g');
printf 'obase=2\nibase=10\n%s\n' "$NUMS" | bc -l \
| sed -e 's/^/0000000/' -e 's/.*\(.\{8\}\)/\1/' \
| xargs printf '%s %s %s %s\n'
}
range2net(){
PREFIX=$(ip2bin "$@" | sed -e 'N;s/^\(.*\).*\n\1.*$/\1/' -e 's/ //g')
LEN=$(wc -c <<<"$PREFIX")
printf '%s/%d\n' "$1" $(( $LEN - 1 ))
}
cmd() { apropos "$@" | egrep '\((1|8)' | less; }
lt() { /bin/ls -lt "$@" | head; }
man2text() { zcat -f $(man -w -- "$1") |groff -Tascii -mandoc; }
rand() { echo $(dd if=/dev/urandom bs=1 count=4 2>/dev/null | od -An -tu4); }
textfiles() { file ${*:-*} | grep text | sed 's/:.*//'; }
dec2hex() { if test "$1" -lt 0
then printf -- '-0x%X\n' $((-$1))
else printf '0x%X\n' "$1"
fi
}
dec2bin() { echo "obase=2; ibase=10; $1" |bc; }
hex2dec() { num=$(echo "$1" |tr a-z A-Z); echo "obase=10; ibase=16; $num" |bc; }
hex2bin() { num=$(echo "$1" |tr a-z A-Z); echo "obase=2; ibase=16; $num" |bc; }
bin2hex() { echo "obase=16; ibase=2; $1" |bc; }
bin2dec() { echo "obase=10; ibase=2; $1" |bc; }
# The chr function converts a number to the equivalent ASCII character:
chr() { printf '%s\n' "$@" | awk '{printf("%c",$0);}'; }
# Output the next character:
succ() { gawk -v c="$1" -l ordchr 'BEGIN{print chr(ord(c)+1)}'; }
# Perl version: succ() { perl -sle 'print chr(ord($c)+1)' -- -c="$1"; }
# Pure shell version:
# next () {
# str=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz;
# left=${str##*"$1"};
# printf '%c\n' "$left"
# }
# A substring test: Return sucess if $2 is a substring of $1 (see
# /etc/init.d/functions on Red Hat systems before 2011 and look at strstr):
substring() { [ "${1#*$2*}" != "$1" ]; }
# strip leading zeros from the argument:
strip_zeros ()
{
test -z ${1#${1%%[!0]*}} && echo 0 || echo ${1#${1%%[!0]*}}
}
# Set the Prompt:
# Setting PROMPT_COMMAND this way will set the window title (and icon text):
if ! expr "$(tty)" : "/dev/tty.$" >/dev/null; then
PROMPT_COMMAND='printf "\e]0;$(id -nu)@$(hostname -f): $PWD\a"'
else
PROMPT_COMMAND=
fi
# LEVEL should be set to zero and exported in login script first:
let 'LEVEL = LEVEL + 1'
# If LEVEL is 1 this is a "root" (top-level) window. If not 1,
# this may be a root window if using X, since that fires up xterm
# as a non-login shell. But in that case SHLVL > LEVEL. Tricky!
if [ "$LEVEL" -eq 1 -o "${SHLVL-0}" -ne "$LEVEL" ]
then
PS1='\n\[$(tput bold)\]\u@\h\[$(tput sgr0)\] $PWD\n$PCHAR '
SHLVL=1
LEVEL=1
[ "$PCHAR" = "$" ] && set -o ignoreeof
else
PS1='\n\[$(tput bold)\]\u@\h\[$(tput sgr0)\] ($LEVEL) $PWD\n$PCHAR '
fi
#mydf() {
#\df -hT --sync "$@" | \
# awk '
# NR == 1 { title = $0; next }
# { row[$7] = $0 }
# END { print title
# for (fs in row) print row[fs] | "sort -k7"
# close("sort -k7")
# }
# ' | grep -v '/run/user'
#}