Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 129 lines (105 sloc) 4.575 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
#### SHORTCUTS ####

#editors
alias n='nautilus `pwd` &' # open the working dir in nautilus
alias e='emacs -nw'
alias v='vim -c start'
alias t='thunar' # open the working dir in thunar
alias s='subl' # sublime text
alias nano='nano -c' # show line numbers
alias p='/usr/local/phpstorm/bin/phpstorm.sh'

# searching files
alias f='find | grep' # quick find
alias ack='ack-grep' # http://betterthangrep.com/
alias hl='ack --passthru' # highlight

#misc
alias o='gnome-open' # open a file with gnome's default handler
alias r='fc -s' # run command in bash history
alias g='git' # as i use git so much
alias ss='ge /home/base/bin/sublimetext2/sublime_text'
alias xc='xclip -selection c' # copy stdin to x clipboard
alias eb='$EDITOR ~/.bashrc'
alias sb='source ~/.bashrc'

#development
alias phplint="php -l"
alias phplintall="find . -name '*.php' -exec php -l {} \; | grep -v 'No syntax errors detected'"
#alias jshint='rhino /home/base/projects/jshint/env/rhino.js'
#alias jshintall="find -name '*.js' -exec rhino /home/base/projects/jshint/env/rhino.js {} \;"
alias tailphperror="tail -n 20 -f /var/log/apache2/error.log"
#alias phpunitslow='phpunit --no-configuration --group slow --verbose tests'
alias shortphptags="ack --php '\<\?[^px]'" # find short PHP open tags

#### NETWORK ####

alias myip='/sbin/ifconfig | grep "inet addr" | awk "{print \$2}" | sed s/addr://g | grep -v 127\.0\.0\.1' # get all local ip addresses

alias mydns='wget -qO - http://ifconfig.me/all|grep remote_host|awk "{print \$2 }"'

# serve current directory on port 8000
alias httpserver='myip && python -m SimpleHTTPServer'

# see what hosts respond to pings on your /24 network
alias nmap24='nmap -sP `myip`/24 | grep report | awk " { print \$5 } "'

# make a ssh tunnel from port 2222 on remote host to 22 on your machine
# usage: ssh-tunnel <user@host>
alias ssh-tunnel='ssh -f -N -C -R 2222:127.0.0.1:22'



#### FUNCTIONS ####

# search wikipedia
function wiki () {
  dig +short txt "${*}".wp.dg.cx | sed -e 's/" "//g' -e 's/^"//g' -e 's/"$//g' -e 's/ http:/\n\nhttp:/'
}

function quickref() {
  echo sed -i "s/find/replace/g" filename.txt
  echo find -name '*.txt' -exec sed -i "s/find/replace/g" {} \; -print
}

function mysqlref() {
  echo 'SELECT ... FROM ... WHERE ... ORDER BY ... DESC LIMIT ...'
  echo
echo 'INSERT INTO table1 (id, field2) VALUES (1, value2)'
  echo 'INSERT INTO table1 (id, field2) VALUES (1, value2), (2, value2b)'
  echo 'INSERT INTO table1 SET field1=value_1, field2=value_2'
  echo 'UPDATE table1 SET field1=new_value1 WHERE condition'
  echo 'DELETE FROM table1 WHERE condition'
  echo
echo 'SHOW DATABASES; SHOW TABLES;'
  echo 'DESCRIBE table; SHOW CREATE TABLE table'
  echo 'SHOW PROCESSLIST; KILL process_number'
  echo
echo 'CREATE TABLE table (id INT(11) AUTO_INCREMENT, title VARCHAR(255), PRIMARY KEY (id))'
  echo 'update wp_options set option_value ="http://example.com" where option_name like "home" or option_name like "siteurl"'
}

#google search
goo () { w3m http://gog.is/"$*"; }

# google text to speech
say(){ mplayer -user-agent Mozilla "http://translate.google.com/translate_tts?tl=en&q=$(echo $* | sed 's#\ #\+#g')" > /dev/null 2>&1 ; }



# go up a number of directories
# usage: cdup == "cd .."; cdup 5 == "cd .." x 5
# from picklepete
cdup() {
  levels=${1-1}
  while ((levels--)); do
        cd ..
  done
}

alias ..='cdup' # go up x dirs

# echo some of the output from the last command
# 1st parameter is the line number
# 2nd parameter is the word (optional, gets whole line otherwise)
o() {
  $(history |
      tail -n 2 |
      head -n 1 |
      cut -d " " -f 3-) |
  head -n $1 |
  tail -n 1 |
  awk " { print \$0$2 } "
}

# record the screen
# requires wmctrl, xwininfo and byzanz
# usage: rec <windowname> <seconds> <filename>
# filename should end in flv, gif or ogg/ogv
function rec() {
  X=$(xwininfo -id $(wmctrl -l | grep -i "$1" | head -n 1 | awk '{print $1}') | grep 'Absolute upper-left X:' | awk "{ print \$NF }" )
  Y=$(xwininfo -id $(wmctrl -l | grep -i "$1" | head -n 1 | awk '{print $1}') | grep 'Absolute upper-left Y:' | awk "{ print \$NF }" )
  W=$(xwininfo -id $(wmctrl -l | grep -i "$1" | head -n 1 | awk '{print $1}') | grep 'Width:' | awk "{ print \$NF }" )
  H=$(xwininfo -id $(wmctrl -l | grep -i "$1" | head -n 1 | awk '{print $1}') | grep 'Height:' | awk "{ print \$NF }" )
  echo In 3 seconds will record window "$1" at $X,$Y size $W,$H for $2 seconds to file "$3"
  sleep 3;
  echo Recording
  byzanz-record --x=$X --y=$Y --width=$W --height=$H --delay=0 -c -d $2 "$3"
  echo Done
}
Something went wrong with that request. Please try again.