Permalink
Browse files

Merge branch 'master' of github.com:guille/spot

  • Loading branch information...
rauchg committed Oct 13, 2012
2 parents 647a4fe + d7bcb44 commit 3802d632e52a78b66e5c933a92985d248062c519
Showing with 45 additions and 23 deletions.
  1. +45 −23 spot.sh
View
68 spot.sh
@@ -1,5 +1,7 @@
#!/usr/bin/env bash
+version="0.0.1"
+
# search directory defaults to current
dir=.
@@ -21,7 +23,7 @@ cyan=`echo -e '\033[96m'`
reset=`echo -e '\033[39m'`
# usage info
-function usage {
+usage() {
cat <<EOF
Usage: spot [options] [directory] [term ...]
@@ -32,32 +34,52 @@ function usage {
-i, --insensitive Force case insensitive search.
-C, --no-colors Force avoid colors.
-L, --no-linenums Hide line numbers.
+ -U, --update Update spot(1)
+ -V, --version Output version
-h, --help This message.
EOF
}
+# update spot(1) via git clone
+update() {
+ cd /tmp \
+ && echo "... updating" \
+ && git clone --depth 1 git://github.com/guille/spot.git \
+ && cd spot \
+ && make install \
+ && echo "... updated to $(spot --version)"
+ exit
+}
+
# parse options
-while [[ "$1" =~ "-" ]]; do
- case $1 in
- -s | --sensitive )
- sensitive=1
- ;;
- -i | --insensitive )
- sensitive=
- ;;
- -C | --no-colors )
- colors=
- ;;
- -L | --no-linenums )
- linenums=
- ;;
- -h | --help )
- usage
- exit
- ;;
- esac
- shift
+while [[ "$1" =~ ^- ]]; do
+ case $1 in
+ -V | --version )
+ echo $version
+ exit
+ ;;
+ -s | --sensitive )
+ sensitive=1
+ ;;
+ -i | --insensitive )
+ sensitive=
+ ;;
+ -C | --no-colors )
+ colors=
+ ;;
+ -L | --no-linenums )
+ linenums=
+ ;;
+ -U | --update )
+ update
+ ;;
+ -h | --help )
+ usage
+ exit
+ ;;
+ esac
+ shift
done
# check for directory as first parameter
@@ -99,13 +121,13 @@ fi
# run search
if [ $colors ]; then
- find $dir -type f ! -path '*/.git*' ! -path '*/.svn' -print0 \
+ find "$dir" -type f ! -path '*/.git*' ! -path '*/.svn*' -print0 \
| GREP_COLOR="1;33;40" xargs -0 grep $grepopt "`echo $@`" \
| sed "s/^\([^:]*:\)\(.*\)/ \\
$cyan\1$reset \\
\2 /"
else
- find $dir -type f ! -path '*/.git*' ! -path '*/.svn' -print0 \
+ find "$dir" -type f ! -path '*/.git*' ! -path '*/.svn*' -print0 \
| xargs -0 grep $grepopt "$@" \
| sed "s/^\([^:]*:\)\(.*\)/ \\
\1 \\

0 comments on commit 3802d63

Please sign in to comment.