diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2018-02-12 14:15:09 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2018-02-12 14:15:09 +0100 |
commit | fac3ee4f244ad4b1276855f0890af50741537609 (patch) | |
tree | 49f256238871b3b0674d15d7be69016bc9a734ce | |
parent | 78545af3c86be4d14aef96152b5ec2781277d643 (diff) | |
download | bin-fac3ee4f244ad4b1276855f0890af50741537609.zip bin-fac3ee4f244ad4b1276855f0890af50741537609.tar.gz |
bashrc : add a few functions
-rw-r--r-- | bashrc | 44 |
1 files changed, 44 insertions, 0 deletions
@@ -91,6 +91,50 @@ then export MPD_HOST=bigdaddy; fi + +# FUCTIONS +function lip () { # local ips + ip -c addr | sed -n '/^[1-9]:/p;/inet /p' +} + +function xip () { # external ip + dig +short myip.opendns.com @resolver1.opendns.com +} + +function rman () { # centered man + env COLUMNS=$(($COLUMNS/3*2)) man "${@}" | pr -o $((COLUMNS/3/2)) | less +} + +function xcon () { # external established connections + ss -t -o state established '( dport = :443 || dport = :80 )' \ + | grep -Po '([0-9a-z:.]*)(?=:http[s])' | sort -u \ + | netcat whois.cymru.com 43 | grep -v "AS Name" | sort -t'|' -k3 +} + +function xtract() { + 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" ;; + *.ZIP) unzip "$1" ;; + *.pax) cat "$1" | pax -r ;; + *.pax.Z) uncompress "$1" —stdout | pax -r ;; + *.Z) uncompress "$1" ;; + *.7z) 7z x "$1" ;; + *) echo "don't know how to extract '$1'..." ;; + esac + else + echo "extract: error: $1 is not valid" + fi +} + # SSH SSH_ENV=${HOME}/.ssh/environment function start_agent { |