From fac3ee4f244ad4b1276855f0890af50741537609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 12 Feb 2018 14:15:09 +0100 Subject: bashrc : add a few functions --- bashrc | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/bashrc b/bashrc index 954055e..0ed1f4c 100644 --- a/bashrc +++ b/bashrc @@ -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 { -- cgit v1.1-2-g2b99