-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathzap.sh
43 lines (41 loc) · 1.18 KB
/
zap.sh
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
#!/bin/bash
function zap() {
USAGE="Usage: zap [remember|to|forget|locations] [bookmark]" ;
if [ ! -e ~/.bookmarks ] ; then
mkdir ~/.bookmarks
fi
case $1 in
# create bookmark
remember) shift
if [ ! -f ~/.bookmarks/$1 ] ; then
echo "cd `pwd`" > ~/.bookmarks/"$1" ;
echo "OK, I'll remember it." ;
else
echo "There is already a bookmark named '$1'."
fi
;;
# goto bookmark
to) shift
if [ -f ~/.bookmarks/$1 ] ; then
source ~/.bookmarks/"$1"
else
echo "This bookmark's location has been lost to the void." ;
fi
;;
# delete bookmark
forget) shift
if [ -f ~/.bookmarks/$1 ] ; then
rm ~/.bookmarks/"$1" ;
echo "The '$1' bookmark has been forgotten." ;
else
echo "I can't find a bookmark with that name." ;
fi
;;
# list bookmarks
locations) shift
ls -l ~/.bookmarks/ ;
;;
*) echo "$USAGE" ;
;;
esac
}