-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbm
More file actions
executable file
·57 lines (54 loc) · 1.72 KB
/
bm
File metadata and controls
executable file
·57 lines (54 loc) · 1.72 KB
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
#!/bin/bash
# *********************************************************************** #
# author: fmarcos83 #
# email : fmarcos83@gmail.com #
# An easy and dirty fast way to have a bookmark system #
# *********************************************************************** #
# TODO: add autocompletion
# TODO: I don't like g option, should change to bookmark
# on bm $bookmark
function bm(){
bookmarkfolder=~/.bookmarks
#sanity check to create bookmark file if it doesn't exist yet
if [[ ! -e $bookmarkfolder ]]; then
mkdir $bookmarkfolder
fi
OPTIND=1
while getopts 'lc:d:g:' OPTION;
do
case $OPTION in
# create the bookmark
# TODO: necesary to check if the bookmark already exists
# before creating it
c)
bookmarkname="$OPTARG"
# adding the bookmark
ln -s $(pwd) $bookmarkfolder/$bookmarkname
;;
# deletes the bookmark
d)
bookmarkname="$OPTARG"
rm $bookmarkfolder/$bookmarkname
;;
# lists all the bookmarks
l)
ls $bookmarkfolder/ --color -1
OPTION='l'
;;
# go to bookmark
g)
bookmarkname=$OPTARG;
# resolving the symbolic link
dir=$(readlink $bookmarkfolder/$bookmarkname)
cd $dir/
;;
?)
echo "Very simple bookmark system:"
echo "c) creates a bookmark on the current directory"
echo "d) removes a bookmark"
echo "l) list bookmarks in the system"
echo "g) changes directory to the bookmark"
;;
esac
done
}