-
Notifications
You must be signed in to change notification settings - Fork 0
/
sesame
executable file
·59 lines (56 loc) · 1.12 KB
/
sesame
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
#!/bin/bash
#
# > sesame <
#
# Sugar on top of find for opening multiple files with similar properties in various applications.
#
# parisminton@da.ydrea.ms
#
# vrs="v 0.3"
# last_change="6/17/15"
OLD_IFS=$IFS
IFS=$(echo -en "\n\b") # new separator is newline followed by backspace...
arg_array=()
app=""
mod=""
dir=$PWD
dur="-5m"
ftype="f"
find_stuff=false
for arg in $*; do
if [[ $arg =~ \.app$ || -L $arg ]]; then
mod="-a"
app=$arg
if [[ $arg == $photo ]]; then
# I'm probably trying to open a screen shot
# that went straight to the desktop
find_stuff=true
if [[ $dir == $PWD ]]; then
dir=~/Desktop
fi
fi
continue
fi
if [[ -d $arg ]]; then
find_stuff=true
dir=$arg
continue
fi
if [[ $arg =~ -[0-9][0-9]*[smhdw]$ ]]; then
find_stuff=true
dur=$arg
continue
fi
if [[ $arg =~ ^[fdl]$ ]]; then
find_stuff=true
ftype=$arg
continue
fi
arg_array[${#arg_array[@]}]=$arg
done
if [[ $find_stuff == true ]]; then
find $dir/* -mtime $dur -type $ftype -exec open $mod $app {} \;
else
open $mod $app ${arg_array[*]}
fi
IFS=$OLD_IFS