I have this in my .bashrc
#shortcut for CTRL+C and CTRL+V alias c-c='xclip -sel clip' alias c-v='xclip -o -sel clip'
function find-all() { python -c "import re import sys for i in re.findall('$1', sys.stdin.read()): if type(i) == type(''): print i else: print i[0]" } And when I have html source code in clipboard and want to find all links I use
c-v | find-all 'href="([^"]*)"' | c-c And I have all urls in clipboard
I also have this function
function lsq(){ ls -lh $@ | tr -s ' ' | cut -d' ' -f5,8 } which display size (human readable) and filename.
alias temp='cat /proc/acpi/thermal_zone/THRM/temperature' this alias is for show temerature
function separate() { python -c "import sys,re; print '$1'.join(re.split('\s*', sys.stdin.read().strip()))"; } with this function I can calculate product or sum of arguments.
alias sum='separate + | bc' alias product='separate * | bc' function split-join() { python -c "import sys,re; print '$2'.join(re.split('$1', sys.stdin.read().strip()))"; } This is usefull function which split standard input separated by regex and then join the result.
function factorial() { seq -s* $1 | bc } factorial function
function wiki() { dig +short txt $1.wp.dg.cx; } This function display wiki text over DNS
I also have three color funcions
function blue() { echo -e "\x1b[34m\x1b[1m"$@"\x1b[0m"; } function green() { echo -e "\x1b[32m\x1b[1m"$@"\x1b[0m"; } function red() { echo -e "\x1b[31m\x1b[1m"$@"\x1b[0m"; }
function md5check() { test `md5sum $2 | cut -d' ' -f1` = "$1" && green [OK] || red [FAIL] } This function validate file md5 hash.
this will show error message for a given code
function strerror() { python -c "import os; print os.strerror($1)"; } You can print all messages with
alias all-errors='for i in `seq 131`; do echo -n "$i: "; strerror $i; done'