Introduction
Introduction Statistics Contact Development Disclaimer Help
bmks - sites - public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log
Files
Refs
---
bmks (2497B)
---
1 #! /bin/bash
2
3 # set prefered launcher
4 PREFERED_LAUNCHER=dmenu
5 # set path where urls will be stored
6 URL_FILE_PATH=$HOME/.bmks/
7 # name of file urls will be stored in
8 URL_FILE_NAME=urls
9
10 show_usage() {
11 printf "bmks: unix bookmark management that sucks less
12
13 usage:
14 bmks help
15 show this help message
16 bmks add <url>
17 add a new bookmark
18 bmks del
19 remove a bookmark
20 bmks ls
21 show all bookmarks
22 bmks dmenu
23 manual switch for displaying bookmarks in dmenu
24 bmks fzf
25 manual switch for displaying bookmarks in fzf
26
27 Configuration is done by directly editing the script. Two launchers are …
28
29 If you would prefer to have your bookmarks stored in alternate location …
30 }
31
32 bmks_add() {
33 [ -z "$url" ] && printf "Error: url must be provided\n\n" && sho…
34 printf "Description: "
35 read description
36 [ -z "$description" ] && echo "$url" >> $URL_FILE_PATH/$URL_FILE…
37 [ -n "$description" ] && echo "$description - $url" >> $URL_FILE…
38 }
39
40 bmks_ls() {
41 bmks_check
42 cat $URL_FILE_PATH/$URL_FILE_NAME | sort
43 }
44
45 bmks_del() {
46 bmks_check
47 case $PREFERED_LAUNCHER in
48 dmenu) sed -i "/$(cat $URL_FILE_PATH/$URL_FILE_NAME | so…
49 fzf) sed -i "/$(cat $URL_FILE_PATH/$URL_FILE_NAME | sort…
50 esac
51 }
52
53 bmks_display() {
54 bmks_check
55 case $PREFERED_LAUNCHER in
56 dmenu) cat $URL_FILE_PATH/$URL_FILE_NAME | sort | dmenu …
57 fzf) cat $URL_FILE_PATH/$URL_FILE_NAME | sort | fzf | aw…
58 esac
59 }
60
61 bmks_check() {
62 [ ! -s $URL_FILE_PATH/$URL_FILE_NAME ] && printf "Error: No book…
63 }
64
65 [ ! -d $URL_FILE_PATH ] && mkdir $URL_FILE_PATH
66 [ ! -f $URL_FILE_PATH/$URL_FILE_NAME ] && touch $URL_FILE_PATH/$URL_FILE…
67
68 case "$1" in
69 "help") show_usage ;;
70 "add") url=$2; bmks_add ;;
71 "del") bmks_del ;;
72 "ls") bmks_ls ;;
73 "dmenu") PREFERED_LAUNCHER=$1; bmks_display ;;
74 "fzf") PREFERED_LAUNCHER=$1; bmks_display ;;
75 *) bmks_display ;;
76 esac
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.