12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #!/bin/ksh
- #
- # FSRC = Find SouRCe
- #
- # Find file. Limit search to a project directory tree, and apply
- # precedence rule (i.e. ignore files that are overwritten with another
- # file in the project). In doing so, stops in the first directory with
- # one or more matching file(s).
- #
- #
- # ARGUMENT
- # --------
- # File name. Patterns matching (a/k/a globbing), and word splitting are
- # ON.
- #
- # OPTIONS
- # --------
- #
- # -r RCFILE : rc file (default is $rcfile, if defined, or the
- # most recent. See SETTING section.)
- #
- # -e|c|v|l : to edit found file(s) with emacs|emacsclient|less|vi
- #
- #
- # SETTING : specify your TM5 dir and default rc file in SETTINGS
- # --------- section in the script.
- #
- #
- # EXAMPLES
- # ---------
- #
- # To find & list files : fsrc "*chem*"
- #
- # To find & edit files : fsrc -c "emission.F90"
- #
- #
- # 3 Jan 2011 - P. Le Sager - v0
- #
- ########################################################
- #set -x
- USAGE="\
- Find SouRCe : look for FILE in TM5 source dirs.
-
- usage: ${0##*/} [-r RCFILE] FILE_PATTERN
-
- "
- #----------------
- # SETTINGS
- #----------------
- # TM5 dir
- TM=$HOME/TM5MP
- # default RC file
- rcfile='pycasso-tm5_chembase.rc'
- cd $TM
- # ------------------------------
- # default command and options
- # ------------------------------
- while getopts :r: OPT; do
- case $OPT in
- r) rcfile=$OPTARG
- ;;
- *) print "$USAGE"
- exit 2
- esac
- done
- shift $(( OPTIND - 1 ))
- # At least one argument
- [ $# -eq 0 ] && print "$USAGE" && exit 1
- # Use the most recent rc file if not passed and no default
- [[ -f $rcfile ]] || rcfile=$(ls -tL *.rc)
- # list of files
- file=$(${0%/*}/get_tmflist -d $TM "$rcfile")
- find $file -name "$@"
- exit
|