-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdotbash_find
48 lines (39 loc) · 1.56 KB
/
dotbash_find
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
#!/bin/bash
#
# .bash_find
#
# Bash helpers for find and search from the command line
#
#
# Some systems I use don't have a decent 'find' implentation so
#
# Lets look for gfind first (The GNU find on Solaris)
FIND=$(find_alternatives "gfind" "find")
alias find="$FIND"
FIND_VERSION=`find --version 2>/dev/null`
if [ "${FIND_VERSION:0:8}" == "GNU find" ]; then
# Some nice find expressions
FIND_BACKUPS=" -name '.#*' -o -name '#*#' -o -name '*\.~*.~' -o -path '*./CVS/*.'"
FIND_CVS=" -path '*./CVS/.*' "
FIND_CCODE=" -iname '*.[chS]' -or -iname '*.cc' "
FIND_CHEAD=" -iname '*.h' "
# and search code for stuff (when I figure out proper expansion and quuting I'll make this neater)
#alias sc="find . -iname '*.[chS]' -or -iname '*.cc' -and -not \( -name '.#' -o -name '#*#' -o -name '*\.~*.~' -o -path '*./CVS/*.' \) -print0 | xargs -0 grep -H "
alias f="$FIND -iname"
alias sc="$FIND . \( $FIND_CCODE \) -and -not \( $FIND_BACKUPS -o $FIND_CVS \) -print0 | xargs -0 grep -H"
# alias sh="find . -iname '*.h' -print0 | xargs -0 grep -H "
alias sa="$FIND . -xtype f -print0 | xargs -0 grep -H "
else
#
# Who knows how standard unix is, its not GNU so probably not
#
# Lets assume both find and grep are borken
#
# Find files under here
alias f="$FIND . -name"
# and search code for stuff
alias sc="$FIND . -name '*.[chS]' -o -name '*.cc' | xargs grep "
# alias sh="find . -name '*.h' | xargs grep "
alias sa="$FIND -L . -type f | xargs grep "
fi
alias .find=". $DOTFILES_DIR/dotbash_find"