bashrc

Bash Completion

Arch Linuxpacman -S bash-completion nmap
Gentoo Linuxemerge -av bash-completion nmap

normalem User's bashrc

nano ~/.bashrc

~/.bashrc

# ~/.bashrc

if [[ $- != *i* ]] ; then
    # Shell is non-interactive.  Be done now!
    return
fi

export LC_MESSAGES="C"

# prompt only the last 2 dirs
PROMPT_DIRTRIM=2

# for setting bash history
HISTSIZE=5000
HISTFILESIZE=100000
HISTCONTROL=ignoredups:ignorespace

# PS1 = user@hostname working directory
PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w'

# if git-prompt.sh exist, prompt git-branch inside a git directory, else only '$'
if [ -f /usr/share/git/git-prompt.sh ]; then
    . /usr/share/git/git-prompt.sh
    GIT_PS1_SHOWDIRTYSTATE=1
    GIT_PS1_SHOWSTASHSTATE=1
    GIT_PS1_SHOWUPSTREAM="auto"
    PS1+='\[\033[01;33m\]$(__git_ps1 " (%s)")\[\033[01;34m\] \$\[\033[00m\] '
else
    PS1+='\[\033[01;34m\] \$\[\033[00m\] '
fi

# source .bash_aliases if exist
if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# source .bash_functions if exist
if [ -f ~/.bash_functions ]; then
    . ~/.bash_functions
fi

nano ~/.bash_aliases

~/.bash_aliases

alias p='pwd'
alias x='exit'
alias ls='ls --all --color=auto'
alias ll='ls -l --human-readable --all --color=auto'
alias ltr='ls -lt --reverse --human-readable --all --color=auto'
alias lSr='ls -lS --reverse --human-readable --all --color=auto'
alias pastebinit='pastebinit -b http://pastebin.ca'
alias sehi='history | grep'
alias nano='nano -w'
alias home='cd ~'
alias sshlibreelec='ssh root@libreelec'
alias sshlaaka='ssh root@laaka'
alias ssharch='ssh michael@arch'
alias sshrbpi2='ssh michael@rbpi2'
alias sshcubietruck='ssh michael@cubietruck'
alias sshopenhab='ssh michael@openhab'

nano ~/.bash_functions

~/.bash_functions

function extract() {
    if [ -f $1 ] ; then
        case $1 in
            *.tar.bz2)  tar xvjf $1    ;;
            *.tar.gz)   tar xvzf $1    ;;
            *.tar.xz)   tar Jxvf $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 "'$1' cannot be extracted via >extract<" ;;
        esac
    else
        echo "'$1' is not a valid file!"
    fi
}

# what's up
function wup() {
    nmap -sn 192.168.55.0/24 -oG - | awk '$4=="Status:" && $5=="Up" {print $2, $3}'
}