mattman (owner)

Revisions

gist: 87360 Download_button fork
public
Public Clone URL: git://gist.github.com/87360.git
Text only
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
#!/bin/sh
 
# cd into matching gem directory ("cd -" friendly)
cdgem() {
  local gempath=$(gem env gemdir)/gems
  if [[ $1 == "" ]]; then
cd $gempath
    return
fi
local gem=$(ls $gempath | g $1 | sort | tail -1)
  if [[ $gem != "" ]]; then
cd $gempath/$gem
  fi
}
 
_cdgem() {
  COMPREPLY=($(compgen -W '$(ls `gem env gemdir`/gems)' -- ${COMP_WORDS[COMP_CWORD]}))
  return 0;
}
complete -o default -o nospace -F _cdgem cdgem;
 
# check for a rake task on the current dir
function rake_exists? {
  [[ -f Rakefile && $(rake -T | g $1 | wc -l) -gt 0 ]]; return $?
}
 
# get current revision of a repo
svn_revision() {
  svn info $@ | awk '/^Revision:/ {print $2}'
}
 
# print the log or 'no changes' after an update
svn_up_and_log() {
  local old_rev=$(svn_revision $@)
  local first_up=$((${old_rev} + 1))
  svn up -q $@
  if [ $(svn_revision $@) -gt ${old_rev} ]; then
svn log -v -rHEAD:${first_up} $@
  else
echo "No changes."
  fi
}
 
# tag a directory in a command to come to it later
tag() {
  alias $1='cd $PWD'
}
 
# alias last command
a() {
  x=`history 1 | sed 's/.\{7\}//'`;
  alias ${1}="${x}";
}
 
# True if a domain name is available
domainavailable() {
  if whois $1 | grep "No match for" &> /dev/null; then
echo "$1 is available"
    return 0
  else
echo "$1 is not available"
    return 1
  fi
}
 
# Check all domains passed as arguments and print those available
availabledomains() {
  for f in $@; do
domainavailable $f &> /dev/null && echo $f;
  done
}
 
# CD back to current git's project base dir
cdg() {
  local cdup=$(git-rev-parse --show-cdup 2> /dev/null)
  if [ $? == 0 ]; then
if [ -z "$cdup" ]; then
cdup=.
    fi
cd $cdup/$1
  else
echo "Not in a git repository"
    return $?
  fi
}
 
# Use ruby as a calculator"
calc() {
  ruby -e 'include Math; puts eval(ARGV.join(" "))' $@;
}
 
# send HUP to the passed named process
hup() {
  kill -HUP `pidof $1`;
}