-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfunctions
38 lines (34 loc) · 856 Bytes
/
functions
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
if [ -f ~/git-config/git-functions ]; then
. ~/git-config/git-functions
fi
find-up () {
path=$(pwd)
while [[ "$path" != "" && ! -e "$path/$1" ]]; do
path=${path%/*}
done
echo "$path"
}
# Find up could use a version that takes a second param of relateive
# or absolute path. Not done yet. This works for child relative paths:
#
# find-up () {
# path=${2-$(pwd)}
# while [[ "$path" != "" && ! -e "$path/$1" ]]; do
# path=${path%/*}
# done
# echo "$path"
# }
findi () {
if [[ $# -eq 0 ]]; then
echo 'Simplifies use of find -maxdepth 1 -iname "*...*"'
echo 'Usage: findi [path] "<wild-card term>"'
echo 'e.g. findi ~ ".c*"'
return 1
fi
path="."
if [[ $# -ge 2 ]]; then
path=$1
shift
fi
find $path -maxdepth 1 -iname "$1" 2> /dev/null
}