buku/README.md

270 lines
12 KiB
Markdown
Raw Normal View History

# Buku
2015-11-10 01:15:35 -06:00
![Screenshot](http://i.imgur.com/UPKcSuN.png)
2015-11-10 01:15:35 -06:00
2016-02-28 08:11:27 -06:00
`buku` (formerly `markit`) is a cmdline bookmark management utility written in Python3 and SQLite3. `buku` exists because of my monumental dependency on <a href="http://historio.us/">historious</a>. I wanted the same database on my local system. However, I couldn't find an equally flexible cmdline solution. Hence, `Buku` (after my son's nickname).
2016-02-28 05:08:04 -06:00
You can add bookmarks to `buku` with title and tags, optionally fetch page title from web, search by keywords for matching tags or title or URL, update and remove bookmarks. You can open the URLs from search results directly in the browser. You can encrypt or decrypt the database file manually, optionally with custom number of hash passes for key generation.
2016-02-28 05:08:04 -06:00
The SQLite3 database file is stored in `$HOME/.cache/buku/bookmarks.db` for each user.
2016-02-28 05:08:04 -06:00
2016-02-28 08:32:10 -06:00
`buku` is **GPLv3** licensed. Copyright (C) 2015 [Arun Prakash Jana](mailto:engineerarun@gmail.com).
2015-11-08 16:04:49 -06:00
2016-02-28 05:08:04 -06:00
If you find `buku` useful, please consider donating via PayPal.
2016-03-10 08:44:18 -06:00
[![Donate Button](https://img.shields.io/badge/paypal-donate-orange.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RMLTQ76JSXJ4Q)
2016-02-28 05:08:04 -06:00
# Table of Contents
- [Features](#features)
- [Installation](#installation)
2016-02-28 08:11:27 -06:00
- [Dependencies](#dependencies)
- [Installating from source](#installing-from-source)
- [Running as a standalone utility](#running-as-a-standalone-utility)
- [Installing with a package manager](#installing-with-a-package-manager)
2016-02-28 05:08:04 -06:00
- [Usage](#usage)
2016-02-28 08:11:27 -06:00
- [Operational notes](#operational-notes)
2016-02-28 08:32:10 -06:00
- [cmdline help](#cmdline-help)
2016-02-28 05:08:04 -06:00
- [Examples](#examples)
- [Contributions](#contributions)
- [Developers](#developers)
2015-11-08 16:04:49 -06:00
# Features
- Add, update or remove a bookmark
- Add tags to bookmarks
2015-12-20 02:36:37 -06:00
- Manual password protection using AES256 encryption algorithm
- Optionally fetch page title data from the web (default: disabled)
- Add or update page title offline manually
2015-11-08 16:04:49 -06:00
- Use (partial) tags or keywords to search bookmarks
2015-11-11 06:29:38 -06:00
- Any or all search keyword match options
- Unique URLs to avoid duplicates, show index if URL already exists
- Open bookmark in browser using index
2015-11-08 16:04:49 -06:00
- Open search results in browser
2016-03-19 11:11:59 -05:00
- Modify or delete tags in DB
- Show all unique tags sorted alphabetically
2015-11-08 16:04:49 -06:00
- Browser (Chromium and Firefox based) errors and warnings suppression
2015-11-09 23:23:35 -06:00
- Show single bookmark by ID or all bookmarks in a go
2015-11-13 05:25:42 -06:00
- Refresh all bookmarks online
2016-03-20 00:53:59 -05:00
- Auto-compact DB on a single bookmark removal
- Delete all bookmarks from DB
- Add a bookmark at N<sup>th</sup> index, to fill deleted bookmark indices
2015-11-10 06:49:09 -06:00
- Secure parameterized SQLite3 queries to access database
2015-11-08 16:04:49 -06:00
- Handle first level of redirections (reports IP blocking)
- Unicode in URL works
- UTF-8 request and response, page character set detection
2015-11-08 16:04:49 -06:00
- Works with Python 3.x
- Coloured output for clarity
2015-11-13 05:25:42 -06:00
- Easily create compatible batch add or update scripts
2015-11-11 06:29:38 -06:00
- Unformatted selective output (for creating batch update scripts)
2015-11-08 16:04:49 -06:00
- Manpage for quick reference
- Optional debug information
- Fast and clean (no ads or clutter)
- Minimal dependencies
- Open source and free
# Installation
2016-02-28 08:11:27 -06:00
## Dependencies
`buku` requires Python 3.x to work.
2015-11-08 16:04:49 -06:00
2016-02-28 08:11:27 -06:00
For optional encryption support, install PyCrypto module. Run:
$ sudo pip3 install pycrypto
or on Ubuntu:
$ sudo apt-get install python3-crypto
## Installing from source
If you have git installed, run:
$ git clone https://github.com/jarun/buku/
or download the latest [stable release](https://github.com/jarun/Buku/releases/latest) or [development version](https://github.com/jarun/buku/archive/master.zip).
Install to default location:
$ sudo make install
or, a custom location (PREFIX):
$ PREFIX=/path/to/prefix make install
2015-11-08 16:04:49 -06:00
To remove, run:
2016-02-28 08:11:27 -06:00
$ sudo make uninstall
or, if you have installed to a custom location (PREFIX):
2015-11-08 16:29:17 -06:00
2016-02-28 08:11:27 -06:00
$ PREFIX=/path/to/prefix make uninstall
You may need to use `sudo` with `PREFIX` depending on your permissions on destination directory.
2016-02-28 08:11:27 -06:00
## Running as a standalone utility
`buku` is a standalone utility. From the containing directory, run:
$ ./buku
## Installing with a package manager
`buku` is also available on
- [AUR](https://aur.archlinux.org/packages/buku/) for Arch Linux;
- Void Linux repos. Run: `$ sudo xbps-install -S buku`
2016-03-16 22:23:50 -05:00
- [Homebrew](http://braumeister.org/formula/buku) for OS X
2016-02-09 00:12:08 -06:00
2015-11-08 16:29:17 -06:00
# Usage
2016-02-28 08:11:27 -06:00
## Operational notes
- It's advisable to copy URLs directly from the browser address bar, i.e., along with the leading `http://` or `https://` token. `buku` looks up title data (found within <title></title> tags of HTML) from the web ONLY for fully-formed HTTP(S) URLs.
- If the URL contains characters like `;`, `&` or brackets they may be interpreted specially by the shell. To avoid it, add the URL within single `'` or double `"` quotes.
2015-11-10 01:15:35 -06:00
- The same URL cannot be added twice. You can update tags and re-fetch title data. You can also delete it and insert at the same index.
- You can either add or update or delete record(s) in one instance. A combination of these operations is not supported in a single run.
- Search works in mysterious ways:
2015-11-11 06:29:38 -06:00
- Substrings match (`match` matches `rematched`) for URL, tags and title.
- All the keywords are treated together as a `single` tag in the `same order`. Bookmarks with partial or complete tag matches are shown in results.
- `-s` : match any of the keywords in URL or title. Order is irrelevant.
- `-S` : match all the keywords in URL or title. Order is irrelevant.
- Search results are indexed serially. This index is different from actual database index of a bookmark reord which is shown within `()` after the URL.
- Encryption support is manual. Database file should be unlocked (`-k`) before using buku and locked (`-l`) afterwards. Note that the database file is <i>unecrypted on creation</i>. AES256 is used for encryption. Optionally specify (`-t`) the number of hash iterations to use to generate key. Default is 8 iterations.
2016-02-28 05:08:04 -06:00
2016-02-28 08:32:10 -06:00
## cmdline help
2016-02-28 08:11:27 -06:00
Usage: buku [OPTIONS] KEYWORDS...
Bookmark manager. Your private Google.
Options
-a URL tag 1, tag 2, ... add URL as bookmark with comma separated tags
2016-03-20 00:53:59 -05:00
-d N delete entry at DB index N (from -P), move last entry to N
2016-02-28 08:11:27 -06:00
-D delete ALL bookmarks
-g show all tags (sorted alphabetically)
2016-02-28 08:11:27 -06:00
-i N insert entry at DB index N, useful to fill deleted index
-k decrypt (unlock) database file
-l encrypt (lock) database file
-m manually add or update the title offline
2016-02-28 08:11:27 -06:00
-o N open URL at DB index N in browser
-p N show details of bookmark record at DB index N
-P show all bookmarks along with index from DB
-R refresh all bookmarks, tags retained
2016-03-19 11:11:59 -05:00
-r oldtag [newtag] replace oldtag with newtag in DB, deletes oldtag if newtag empty
2016-02-28 08:11:27 -06:00
-s keyword(s) search all bookmarks for a (partial) tag or any keyword
-S keyword(s) search all bookmarks for a (partial) tag or all keywords
-t N use N (> 0) hash iterations to generate key, works with -k, -l
-u N update all fields of entry at DB index N
2016-02-28 08:11:27 -06:00
-w fetch title info from web, works with -a, -i, -u
-x N works with -P, N=1: show only URL, N=2: show URL and tag
-z show debug information
any other option shows help and exits buku
Keys
1-N open Nth search result in browser. Enter exits buku.
2016-02-28 05:08:04 -06:00
2015-11-08 16:32:12 -06:00
# Examples
1. **Add** a new bookmark with title `Linux magazine` & tags `linux news` and `open source`:
2016-02-28 08:32:10 -06:00
$ buku -a -m 'Linux magazine' http://tuxdiary.com linux news, open source
2016-02-28 08:32:10 -06:00
Added at index 15012014
Note that URL must precede tags. Multiple words in title must be within quotes.
2015-11-10 00:34:37 -06:00
The assigned automatic index 15012014 is unique, one greater than highest index already in use in database.
2016-02-28 08:32:10 -06:00
2. Add a bookmark, **fetch page title** information from web:
$ buku -a -w http://tuxdiary.com linux news, open source
Title: [TuxDiary | Linux, open source and a pinch of leisure.]
Added at index 15012014
3. **Update** existing bookmark at index 15012014 with a new tag:
$ buku -u 15012014 -w http://tuxdiary.com linux news, open source, magazine
Title: [TuxDiary | Linux, open source and a pinch of leisure.]
2016-03-19 12:44:27 -05:00
Updated index 15012014
Tags are updated too. Original tags are removed.
2016-02-28 08:32:10 -06:00
4. Update or **refresh full DB**:
$ buku -R
2016-03-19 12:53:18 -05:00
This operation does not modify the existing tags. Only titles are refreshed.
2016-02-28 08:32:10 -06:00
5. **Delete** bookmark at index 15012014:
$ buku -d 15012014
2016-03-20 00:53:59 -05:00
Index 15012020 moved to 15012014
The last index is moved to the deleted index to keep the DB compact.
2016-02-28 08:32:10 -06:00
6. **Delete all** bookmarks:
$ buku -D
2016-03-18 13:15:44 -05:00
7. List **all unique tags** alphabetically:
$ buku -g
8. **Insert** a bookmark at index 15012014 (fails if index or URL exists in database):
2016-02-28 08:32:10 -06:00
$ buku -i 15012014 -w http://tuxdiary.com/about linux news, open source
Title: [A journey with WordPress | TuxDiary]
Added at index 15012014
2015-11-10 00:34:37 -06:00
This option is useful in filling deleted indices from database manually.
2016-03-19 11:11:59 -05:00
9. **Replace a tag** with new one:
$ buku -r 'old tag' 'new tag'
2016-03-19 11:11:59 -05:00
10. **Delete a tag** from DB:
$ buku -r 'old tag'
2016-03-19 11:11:59 -05:00
11. **Show info** on bookmark at index 15012014:
2016-02-28 08:32:10 -06:00
$ buku -p 15012014
2016-03-19 11:11:59 -05:00
12. **Show all** bookmarks with real index from database:
2016-02-28 08:32:10 -06:00
$ buku -P
2016-03-19 11:11:59 -05:00
13. **Open URL** at index 15012014 in browser:
2016-02-28 08:32:10 -06:00
$ buku -o 15012014
2016-03-19 11:11:59 -05:00
14. **Search** bookmarks for a tag matching `*kernel debugging*` or **ANY** of the keywords `*kernel*` and `*debugging*` in URL or title (separately):
2016-02-28 08:32:10 -06:00
$ buku -s kernel debugging
2016-03-19 11:11:59 -05:00
15. **Search** bookmarks for a tag matching `*kernel debugging*` or **ALL** the keywords `*kernel*` and `*debugging*` in URL or title (separately):
2016-02-28 08:32:10 -06:00
$ buku -S kernel debugging
2016-03-19 11:11:59 -05:00
16. Encrypt/decrypt DB with **custom number of iterations** to generate key:
2016-02-28 08:32:10 -06:00
$ buku -l -t 15
$ buku -k -t 15
2015-12-22 12:18:55 -06:00
The same number of iterations must be used for one lock & unlock instance.
2016-03-19 11:11:59 -05:00
17. Show **debug info**:
2016-02-28 08:32:10 -06:00
$ buku -z ...
2016-03-19 11:11:59 -05:00
18. More **help**:
2016-02-28 08:32:10 -06:00
$ buku
$ man buku
2016-03-19 11:11:59 -05:00
19. `buku` doesn't have any **import feature** of its own. To import URLs in bulk, create a script with URLs and tags like the following (check TIP below):
2016-02-28 08:32:10 -06:00
#!/bin/bash
buku -aw https://wireless.wiki.kernel.org/ networking, device drivers
buku -aw https://courses.engr.illinois.edu/ece390/books/artofasm/ArtofAsm.html assembly
buku -aw http://www.tittbit.in/
buku -aw http://www.mikroe.com/chapters/view/65/ electronics
buku -aw "http://msdn.microsoft.com/en-us/library/bb470206(v=vs.85).aspx" file systems
buku -aw http://www.ibm.com/developerworks/linux/library/l-linuxboot/index.html boot process
Make the script executable and run to batch add bookmarks.
2016-03-19 11:11:59 -05:00
20. To **update selected URLs** (refresh) along with your tags, first get the unformatted selective output with URL and tags:
2016-02-28 08:32:10 -06:00
$ buku -P -x 2 | tee myurls
Remove the lines you don't need. Add `buku -wu ` in front of all the other lines (check TIP below). Should look like:
2016-02-28 08:32:10 -06:00
#!/bin/bash
buku -wu 50 https://wireless.wiki.kernel.org/ networking, device drivers
buku -wu 51 https://courses.engr.illinois.edu/ece390/books/artofasm/ArtofAsm.html assembly
buku -wu 52 http://www.tittbit.in/
buku -wu 53 http://www.mikroe.com/chapters/view/65/ electronics
buku -wu 54 "http://msdn.microsoft.com/en-us/library/bb470206(v=vs.85).aspx" file systems
buku -wu 55 http://www.ibm.com/developerworks/linux/library/l-linuxboot/index.html boot process
Run the script:
2016-02-28 08:32:10 -06:00
$ chmod +x myurls
$ ./myurls
2016-02-28 05:08:04 -06:00
2016-02-28 08:11:27 -06:00
**TIP:**
2015-11-11 02:31:04 -06:00
To add the same text at the beginning of multiple lines using vim editor:
- Press `Ctrl-v` to select the first column of text in the lines you want to change (visual mode).
- Press `Shift-i` and type the text you want to insert.
- Hit `Esc`, wait 1 second and the inserted text will appear on every line.
2016-02-28 05:08:04 -06:00
2015-11-11 02:31:04 -06:00
Using sed:
2016-02-28 08:11:27 -06:00
$ sed -i 's/^/buku -wu /' filename
2015-11-08 16:04:49 -06:00
2015-11-10 00:34:37 -06:00
# Contributions
I would love to see pull requests with the following features:
- Exact word match (against substring in a word as it works currently. Hint: REGEXP)
- Parse full page data??? Might end up writing a search engine like Google. ;)
2016-02-28 05:08:04 -06:00
# Developers
2016-02-01 08:46:26 -06:00
[Arun Prakash Jana](mailto:engineerarun@gmail.com)
2016-02-28 05:08:04 -06:00
Special thanks to the community for valuable suggestions and ideas.