forked from ajmalsiddiqui/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.functions
47 lines (42 loc) · 1.63 KB
/
.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
38
39
40
41
42
43
44
45
46
47
# This line imports an OS specific functions file if one exists
# Not been tested on any OS other than Mac OSX
# TODO: find a better way than uname to distinguish between linux distros
[ -f ".functions.$( uname )" ] && source ".functions.$( uname )"
# I use playgrounds to experiment with new languages and features
# without making a full fledged project
# This creates a new playground with the name given as a command line arg
play () {
# TODO : redirect io to /dev/null and write custom messages
if [ $# -lt 1 ] ; then
cd "$PATH_TO_PLAYGROUND" && echo 'In playground'
fi
mkdir -p $PATH_TO_PLAYGROUND/$1 && cd $PATH_TO_PLAYGROUND/$1
echo "In playground $1"
}
# Create a new project and cd into it, does NOT check if project already exists
project () {
# TODO : redirect io to /dev/null and write custom messages
if [ $# -lt 1 ] ; then
cd "$PATH_TO_PROJECTS" && echo 'In Projects'
fi
mkdir -p "$PATH_TO_PROJECTS/$1" && cd "$PATH_TO_PROJECTS/$1"
echo "In project $1"
}
# Grep thorughout the files in a dir
# Use this one carefully if you have subdirs filled with shit
# This desperately needs flags to exclude dirs
# TODO add support for grep flags by passing $@ to the grep function, or something like that
grep_dir() {
for i in $( ls ) ; do
if [ -d "$i" ] ; then
cd "$i" && grep_dir "$1"
cd ..
else
grep "$1" "$i" && echo -e "Filename: $( pwd )/$i\n"
fi
done
}
# This should be the last line of the file
# For local changes
# Don't make edits below this
[ -f ".functions.local" ] && source ".functions.local"