2016-04-22 16:11:16 -05:00
< h1 align = "center" > Buku< / h1 >
2015-11-10 01:15:35 -06:00
2016-04-23 00:46:27 -05:00
< p align = "center" >
< a href = "https://aur.archlinux.org/packages/buku" > < img src = "https://img.shields.io/aur/version/buku.svg" alt = "AUR" / > < / a >
< a href = "http://braumeister.org/formula/buku" > < img src = "https://img.shields.io/homebrew/v/buku.svg" alt = "Homebrew" / > < / a >
< a href = "https://github.com/jarun/Buku/releases/latest" > < img src = "https://img.shields.io/github/release/jarun/buku.svg" alt = "Latest release" / > < / a >
< / p >
2016-04-22 16:11:16 -05:00
< p align = "center" >
2016-04-23 09:52:43 -05:00
< a href = "https://asciinema.org/a/6x3nu7ez9t0flk1knhiabwduv" > < img src = "https://asciinema.org/a/6x3nu7ez9t0flk1knhiabwduv.png" alt = "Asciicast" width = "600" / > < / a >
2016-04-22 16:11:16 -05:00
< / p >
2015-11-10 01:15:35 -06:00
2016-04-20 23:59:57 -05:00
`buku` is a powerful cmdline bookmark management utility written in Python3 and SQLite3. When I started writing it, I couldn't find a flexible cmdline solution with a portable database. Hence, `Buku` (after my son's nickname).
2016-02-28 05:08:04 -06:00
2016-04-21 10:29:32 -05:00
You can add bookmarks to `buku` with tags and page title fetched from the web, search, update and remove bookmarks. You can open the URLs from search results directly in the browser. Encryption is supported, optionally with custom number of hash passes for key generation.
2016-02-28 05:08:04 -06:00
2016-04-08 07:50:25 -05:00
`buku` can also handle piped input, which lets you combine it with `xsel` (on Linux) and use a shortcut to add selected or copied text as bookmark without touching the terminal.
2016-03-26 12:21:40 -05:00
Ref: [buku & xsel: add selected or copied URL as bookmark ](http://tuxdiary.com/2016/03/26/buku-xsel/ )
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-04-17 05:07:22 -05:00
Find `buku` useful? If you would like to donate, visit the
2016-04-16 10:06:15 -05: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) page.
2016-02-28 05:08:04 -06:00
2015-11-08 16:04:49 -06:00
# Features
2016-04-19 13:57:58 -05:00
2015-11-08 16:04:49 -06:00
- 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
2016-04-21 10:47:33 -05:00
- Fetch page title from the web (default) or add a custom page title 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
2016-04-19 12:30:06 -05:00
- Search bookmarks by tag
2015-11-09 09:38:44 -06:00
- Unique URLs to avoid duplicates, show index if URL already exists
2015-11-10 05:20:30 -06:00
- Open bookmark in browser using index
2015-11-08 16:04:49 -06:00
- Open search results in browser
2016-04-17 11:07:26 -05:00
- Optional Json formatted output
2016-03-19 11:11:59 -05:00
- Modify or delete tags in DB
2016-03-16 13:03:15 -05:00
- 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
2016-03-25 02:52:52 -05:00
- Show all bookmarks with empty titles or no tags (for bookkeeping)
2015-11-10 05:20:30 -06:00
- 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
2016-04-09 08:15:22 -05:00
- Supports HTTP compression
2016-04-10 08:01:11 -05:00
- Handle multiple HTTP redirections (reports redirected URL, loops, IP blocking)
2015-11-08 16:04:49 -06:00
- Unicode in URL works
2015-11-09 09:38:44 -06:00
- UTF-8 request and response, page character set detection
2016-03-26 11:04:02 -05:00
- Handle piped input
2015-11-08 16:04:49 -06:00
- 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
2016-04-19 13:57:58 -05:00
# Table of Contents
- [Installation ](#installation )
- [Dependencies ](#dependencies )
- [Installing from this repository ](#installing-from-this-repository )
- [Running as a standalone utility ](#running-as-a-standalone-utility )
- [Installing with a package manager ](#installing-with-a-package-manager )
- [Usage ](#usage )
- [Cmdline options ](#cmdline-options )
- [Operational notes ](#operational-notes )
- [Examples ](#examples )
- [Bookkeeping ](#bookkeeping )
- [Contributions ](#contributions )
- [Developers ](#developers )
2015-11-08 16:04:49 -06:00
# Installation
2016-02-28 08:11:27 -06:00
## Dependencies
2015-12-19 14:13:46 -06:00
`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
2016-03-24 03:46:07 -05:00
## Installing from this repository
2016-02-28 08:11:27 -06:00
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:
2016-04-10 07:41:00 -05:00
$ sudo make install
2016-02-28 08:11:27 -06:00
or, a custom location (PREFIX):
$ PREFIX=/path/to/prefix make install
2016-04-10 07:41:00 -05:00
To remove, run:
2015-11-08 16:04:49 -06:00
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.
2015-12-19 12:15:22 -06:00
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
2016-04-22 00:17:00 -05:00
- [AUR ](https://aur.archlinux.org/packages/buku/ ) for Arch Linux
- Void Linux repos ( `$ sudo xbps-install -S buku` )
- [Homebrew ](http://braumeister.org/formula/buku ) for OS X, or its Linux fork, [Linuxbrew ](https://github.com/Linuxbrew/linuxbrew/blob/master/Library/Formula/buku.rb )
2016-02-09 00:12:08 -06:00
2015-11-08 16:29:17 -06:00
# Usage
2016-02-28 05:08:04 -06:00
2016-03-25 13:47:51 -05:00
## Cmdline options
2016-02-28 08:11:27 -06:00
2016-03-20 14:53:57 -05:00
Usage: buku OPTIONS [URL] [TAGS] [KEYWORDS ...]
2016-03-25 11:39:45 -05:00
A private cmdline bookmark manager. Your mini web!
2016-02-28 08:11:27 -06:00
2016-03-25 13:35:11 -05:00
General options
2016-03-25 04:29:19 -05:00
-a URL [tags] add URL as bookmark with comma separated tags
2016-04-20 10:57:53 -05:00
-d N delete entry at DB index N (from -p 0), N=0 deletes all
2016-03-25 13:35:11 -05:00
-g list all tags alphabetically
2016-04-22 12:01:17 -05:00
-m title manually set title, for -a, -i, -u; '-m none' clears title
2016-04-19 13:32:28 -05:00
-s keyword(s) search bookmarks for any keyword
2016-04-20 10:17:47 -05:00
-S keyword(s) search bookmarks with all keywords
2016-04-22 00:07:53 -05:00
-u N [URL] [tags] update fields of the entry at DB index N
The first keyword, if available, is treated as the URL.
If URL is omitted (and -m is not used) the title of entry at
index N is refreshed from the web, N=0 refreshes all titles.
2016-03-25 13:35:11 -05:00
Power toys
2016-03-25 04:29:19 -05:00
-e show bookmarks with empty titles or no tags
2016-03-25 09:12:49 -05:00
-i N insert new bookmark at free DB index N
2016-04-18 10:12:33 -05:00
-j show results in Json format
2016-03-25 04:29:19 -05:00
-k decrypt (unlock) database file
-l encrypt (lock) database file
-o N open URL at DB index N in browser
2016-04-20 10:41:07 -05:00
-p N show details of bookmark record at DB index N, N=0 shows all
2016-03-25 13:35:11 -05:00
-r oldtag [newtag] replace oldtag with newtag, delete oldtag if newtag empty
-t N use N (> 0) hash iterations to generate key, for -k, -l
2016-04-22 00:07:53 -05:00
-x N modify -p behaviour, N=1: show only URL, N=2: show URL & tag
2016-03-25 04:29:19 -05:00
-z show debug information
2016-02-28 08:11:27 -06:00
2016-04-23 00:25:26 -05:00
Prompt keys
2016-04-19 10:46:19 -05:00
1-N open Nth search result in browser
Enter exit buku
2016-02-28 05:08:04 -06:00
2016-02-28 08:11:27 -06:00
## Operational notes
2016-03-25 13:47:51 -05:00
2016-04-24 09:37:51 -05:00
- The SQLite3 database file is stored in:
- **$XDG_DATA_HOME/buku/bookmarks.db**, if XDG_DATA_HOME is defined (first preference) or
- **$HOME/.local/share/buku/bookmarks.db**, if HOME is defined (second preference) or
- the **current directory** , on Windows for example.
- Before version 1.9, `buku` stored its database in ** $HOME/.cache/buku/bookmarks.db**. If the file exists, buku automatically moves it to new location.
2016-04-21 12:48:42 -05:00
- The database index for entries starts from 1. Index 0 is used for special operations like show or refresh or delete all bookmarks.
2015-12-19 14:13:46 -06:00
- 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.
2015-12-07 12:21:05 -06:00
- 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.
2016-03-25 13:47:51 -05:00
- The same URL cannot be added twice. You can update tags and re-fetch title data. You can also insert a new bookmark at a free index.
2015-11-10 01:15:35 -06:00
- 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:
2016-04-19 14:08:39 -05:00
- Case-insensitive.
2016-04-19 13:32:28 -05:00
- Substrings match (`match` matches `rematched` ) for URL, title and tags.
- `-s` : match any of the keywords in URL, title or tags.
- `-S` : match all the keywords in URL, title or tags.
- You can search bookmarks by tag (see example).
2016-03-25 13:47:51 -05:00
- Search results are indexed serially. This index is different from actual database index of a bookmark record which is shown within `()` after the URL.
2016-04-20 10:41:07 -05:00
- When a record is deleted, the last record is moved to the index.
2016-03-25 13:47:51 -05:00
- AES256 is used for encryption. Optionally specify (`-t`) the number of hash iterations to use to generate key. Default is 8 iterations.
2016-04-10 08:01:11 -05:00
- Encryption is optional and manual. If you choose to use encryption, the database file should be unlocked (`-k`) before using buku and locked (`-l`) afterwards. Between these 2 operations, the database file lies unencrypted on the disk, and NOT in memory. Also, note that the database file is < i > unencrypted on creation</ i > .
2016-02-28 05:08:04 -06:00
2015-11-08 16:32:12 -06:00
# Examples
2016-04-21 10:29:32 -05:00
1. **Add** a bookmark with **tags** `linux news` and `open source` , **fetch page title** from the web:
$ buku -a http://tuxdiary.com linux news, open source
Title: [TuxDiary | Linux, open source and a pinch of leisure.]
Added at index 15012014
2016-04-21 10:37:11 -05:00
2. **Add** a bookmark with **manual title** `Linux magazine` & tags `linux news` and `open source` :
2016-02-28 08:32:10 -06:00
2016-03-03 12:18:04 -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
2016-03-03 12:18:04 -06:00
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-04-21 10:37:11 -05:00
3. **Add** a bookmark **without a title** (works for update and insert too):
2016-02-28 08:32:10 -06:00
2016-04-21 10:29:32 -05:00
$ buku -a -m none http://tuxdiary.com linux news, open source
2016-04-21 22:12:17 -05:00
4. **Update** existing bookmark at index 15012014 with new URL and tags, fetch title from the web:
2016-02-28 08:32:10 -06:00
2016-04-21 22:12:17 -05:00
$ buku -u 15012014 http://tuxdiary.com/ linux news, open source, magazine
2016-02-28 08:32:10 -06:00
Title: [TuxDiary | Linux, open source and a pinch of leisure.]
2016-03-19 12:44:27 -05:00
Updated index 15012014
2016-03-19 12:57:37 -05:00
Tags are updated too. Original tags are removed.
2016-04-21 10:37:11 -05:00
5. **Update** or refresh **full DB** with page titles from the web:
2016-02-28 08:32:10 -06:00
2016-04-21 12:48:42 -05:00
$ buku -u 0
2016-04-21 22:18:18 -05:00
This operation does not modify the indexes, URLs or tags. Only titles, if non-empty, are refreshed. Any index other than 0 refreshes title for that index.
2016-04-21 10:29:32 -05:00
6. **Delete** bookmark at index 15012014:
2016-02-28 08:32:10 -06:00
$ 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-04-21 10:29:32 -05:00
7. **Delete all** bookmarks:
2016-02-28 08:32:10 -06:00
2016-04-20 10:57:53 -05:00
$ buku -d 0
2016-04-21 10:29:32 -05:00
8. List **all unique tags** alphabetically:
2016-03-18 13:15:44 -05:00
$ 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
2016-04-21 10:29:32 -05:00
$ buku -i 15012014 http://tuxdiary.com/about linux news, open source
2016-02-28 08:32:10 -06:00
Title: [A journey with WordPress | TuxDiary]
Added at index 15012014
2016-04-21 10:29:32 -05:00
10. **Replace a tag** with new one:
2016-03-19 11:11:59 -05:00
2016-03-19 11:20:14 -05:00
$ buku -r 'old tag' 'new tag'
2016-04-21 10:29:32 -05:00
11. **Delete a tag** from DB:
2016-03-19 11:11:59 -05:00
2016-03-19 11:20:14 -05:00
$ buku -r 'old tag'
2016-04-21 10:29:32 -05:00
12. **Show info** on bookmark at index 15012014:
2016-02-28 08:32:10 -06:00
$ buku -p 15012014
2016-04-21 10:29:32 -05:00
13. **Show all** bookmarks with real index from database:
2016-02-28 08:32:10 -06:00
2016-04-20 10:09:18 -05:00
$ buku -p 0
2016-04-21 10:29:32 -05:00
14. **Open URL** at index 15012014 in browser:
2016-02-28 08:32:10 -06:00
$ buku -o 15012014
2016-04-21 10:29:32 -05:00
15. **Search** bookmarks for **ANY** of the keywords `*kernel*` and `*debugging*` in URL, title or tags:
2016-02-28 08:32:10 -06:00
$ buku -s kernel debugging
2016-04-21 10:29:32 -05:00
16. **Search** bookmarks with **ALL** the keywords `*kernel*` and `*debugging*` in URL, title or tags:
2016-02-28 08:32:10 -06:00
$ buku -S kernel debugging
2016-04-21 10:29:32 -05:00
17. **Search** bookmarks tagged `general kernel concepts` :
2016-04-19 12:30:06 -05:00
2016-04-19 23:03:02 -05:00
$ buku -S ',general kernel concepts,'
2016-04-19 12:30:06 -05:00
Note the commas (,) before and after the tag.
2016-04-21 10:29:32 -05:00
18. 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-04-21 10:29:32 -05:00
19. Show **debug info** :
2016-02-28 08:32:10 -06:00
$ buku -z ...
2016-04-21 10:29:32 -05:00
20. More **help** :
2016-02-28 08:32:10 -06:00
$ buku
$ man buku
2016-03-29 07:43:43 -05:00
## Bookkeeping
2016-03-29 07:47:35 -05:00
1. To list bookmarks with **no title or tags** :
2016-03-29 07:43:43 -05:00
$ buku -e
2016-03-29 07:47:35 -05:00
Use the `-u` option to add title or tags to those entries, if you want to.
2016-03-29 07:43:43 -05:00
2. `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
2016-04-21 10:29:32 -05:00
buku -a https://wireless.wiki.kernel.org/ networking, device drivers
buku -a https://courses.engr.illinois.edu/ece390/books/artofasm/ArtofAsm.html assembly
buku -a http://www.tittbit.in/
buku -a http://www.mikroe.com/chapters/view/65/ electronics
buku -a "http://msdn.microsoft.com/en-us/library/bb470206(v=vs.85).aspx" file systems
buku -a http://www.ibm.com/developerworks/linux/library/l-linuxboot/index.html boot process
2015-12-07 12:21:05 -06:00
Make the script executable and run to batch add bookmarks.
2016-03-29 07:43:43 -05:00
3. 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
2016-04-20 10:09:18 -05:00
$ buku -p 0 -x 2 | tee myurls
2016-04-21 10:29:32 -05:00
Remove the lines you don't need. Add `buku -u ` in front of all the other lines (check TIP below). Should look like:
2016-02-28 08:32:10 -06:00
#!/bin/bash
2016-04-21 10:29:32 -05:00
buku -u 50 https://wireless.wiki.kernel.org/ networking, device drivers
buku -u 51 https://courses.engr.illinois.edu/ece390/books/artofasm/ArtofAsm.html assembly
buku -u 52 http://www.tittbit.in/
buku -u 53 http://www.mikroe.com/chapters/view/65/ electronics
buku -u 54 "http://msdn.microsoft.com/en-us/library/bb470206(v=vs.85).aspx" file systems
buku -u 55 http://www.ibm.com/developerworks/linux/library/l-linuxboot/index.html boot process
2015-11-11 01:48:23 -06:00
Run the script:
2016-02-28 08:32:10 -06:00
$ chmod +x myurls
$ ./myurls
2016-02-28 05:08:04 -06:00
2016-04-06 00:00:19 -05:00
####TIP
2016-04-06 00:04:14 -05:00
Add the same text at the beginning of multiple lines:
2016-04-10 07:41:00 -05:00
**vim**
2015-11-11 02:31:04 -06:00
- 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
2016-04-06 00:04:14 -05:00
**sed**
2016-02-28 08:11:27 -06:00
2016-04-21 10:29:32 -05:00
$ sed -i 's/^/buku -u /' filename
2015-11-08 16:04:49 -06:00
2015-11-10 00:34:37 -06:00
# Contributions
2016-04-07 05:24:06 -05:00
Pull requests are welcome. Some of the features I have in mind are:
2016-04-05 23:57:17 -05:00
- Support subcommands using argparse
2016-04-23 12:24:02 -05:00
- Ubuntu deb package
2016-04-06 04:17:32 -05:00
- Merge bookmark database files (for users who work on multiple systems)
2015-11-10 00:34:37 -06:00
- 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-04-06 00:05:50 -05:00
- Anything else which would add value (please raise an issue for discussion)
2015-11-10 00:34:37 -06:00
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.