-
Notifications
You must be signed in to change notification settings - Fork 3
/
bash_functions
45 lines (39 loc) · 930 Bytes
/
bash_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
########################################################################
#
# qfind - used to quickly find files that contain a string in a directory
#
########################################################################
qfind () {
find . -exec grep -l --no-messages $1 {} \;
return 0
}
########################################################################
#
# up and down -- moving around quickly in the directory structure
#
########################################################################
# A bash script called up so that if I'm in /a/very/deeply/nested/path/somewhere
# and I want to go "up" N directories, I can type 'up N'. To go back to where
# I started I can type 'down N'.
function up( )
{
LIMIT=$1
P=$PWD
for ((i=1; i <= LIMIT; i++))
do
P=$P/..
done
cd $P
export MPWD=$P
}
function down( )
{
LIMIT=$1
P=$MPWD
for ((i=1; i <= LIMIT; i++))
do
P=${P%/..}
done
cd $P
export MPWD=$P
}