项目作者: jarun

项目描述 :
:bookmark: Browser-independent bookmark manager
高级语言: Python
项目地址: git://github.com/jarun/buku.git
创建时间: 2015-11-01T19:53:18Z
项目社区:https://github.com/jarun/buku

开源协议:GNU General Public License v3.0

下载


buku


Latest release
Availability
PyPI
Build Status
Docs Status
Privacy Awareness
License


buku in action!

buku in action!

Introduction

buku is a powerful bookmark manager and a personal textual mini-web.

For those who prefer the GUI, bukuserver exposes a browsable front-end on a local web host server. See bukuserver page for config and screenshots.

When I started writing it, I couldn’t find a flexible command-line solution with a private, portable, merge-able database along with seamless GUI integration. Hence, buku.

buku can import bookmarks from browser(s) or fetch the title, tags and description of a URL from the web. Use your favourite editor to add, compose and update bookmarks. Search bookmarks instantly with multiple search options, including regex and a deep scan mode (handy with URLs).

It can look up broken links on the Wayback Machine. There’s an Easter Egg to revisit random bookmarks.

There’s no tracking, hidden history, obsolete records, usage analytics or homing.

To get started right away, jump to the Quickstart section. buku has one of the best documentation around. The man page comes with examples. For internal details, please refer to the operational notes.

buku is a library too! There are several related projects, including a browser plug-in.

Table of Contents

Features

  • Store bookmarks with auto-fetched title, tags and description
  • Auto-import from Firefox, Google Chrome, Chromium and MS Edge
  • Open bookmarks and search results in browser
  • Browse cached page from the Wayback Machine
  • Text editor integration
  • Lightweight, clean interface, custom colors
  • Powerful search options (regex, substring…)
  • Continuous search with on the fly mode switch
  • Portable, merge-able database to sync between systems
  • Import/export bookmarks from/to HTML, XBEL, Markdown, RSS or Orgfile
  • Smart tag management using redirection (>>, >, <<)
  • Multi-threaded full DB refresh
  • Manual encryption support
  • Shell completion scripts, man page with examples
  • Privacy-aware (no unconfirmed user data collection)

Installation

Dependencies

Feature Dependency
Lang, SQLite Python 3.8+
HTTPS certifi, urllib3
Encryption cryptography
HTML beautifulsoup4, html5lib

To copy URL to clipboard buku uses xsel (or xclip) on Linux, pbcopy (default installed) on OS X, clip (default installed) on Windows, termux-clipboard on Termux (terminal emulation for Android), wl-copy on Wayland. If X11 is missing, GNU Screen or tmux copy-paste buffers are recognized.

From a package manager

To install buku with all its dependencies from PyPI, run:

  1. # pip3 install buku

You can also install buku from your package manager. If the version available is dated try an alternative installation method.

Packaging status (expand)




Packaging status


Unlisted packagers:




PyPI (pip3 install buku)

● Termux (pip3 install buku)


Release packages

Auto-generated packages (with only the cli component) for Arch Linux, CentOS, Debian, Fedora, openSUSE Leap and Ubuntu are available with the latest stable release.

NOTE: CentOS may not have the python3-beautifulsoup4 package in the repos. Install it using pip3.

From source

If you have git installed, clone this repository. Otherwise download the latest stable release or development version (risky).

Install the dependencies. For example, on Ubuntu:

  1. $ apt-get install ca-certificates python3-urllib3 python3-cryptography python3-bs4

Install the cli component to default location (/usr/local):

  1. $ sudo make install

To remove, run:

  1. $ sudo make uninstall

PREFIX is supported, in case you want to install to a different location.

Running standalone

buku is a standalone utility. From the containing directory, run:

  1. $ chmod +x buku
  2. $ ./buku

Shell completion

Shell completion scripts for Bash, Fish and Zsh can be found in respective subdirectories of auto-completion/. Please refer to your shell’s manual for installation instructions.

Usage

Command-line options

  1. usage: buku [OPTIONS] [KEYWORD [KEYWORD ...]]
  2. Bookmark manager like a text-based mini-web.
  3. POSITIONAL ARGUMENTS:
  4. KEYWORD search keywords
  5. GENERAL OPTIONS:
  6. -a, --add URL [+|-] [tag, ...]
  7. bookmark URL with comma-separated tags
  8. (prepend tags with '+' or '-' to use fetched tags)
  9. -u, --update [...] update fields of an existing bookmark
  10. accepts indices and ranges
  11. refresh title and desc if no edit options
  12. if no arguments:
  13. - update results when used with search
  14. - otherwise refresh all titles and desc
  15. -w, --write [editor|index]
  16. edit and add a new bookmark in editor
  17. else, edit bookmark at index in EDITOR
  18. edit last bookmark, if index=-1
  19. if no args, edit new bookmark in EDITOR
  20. -d, --delete [...] remove bookmarks from DB
  21. accepts indices or a single range
  22. if no arguments:
  23. - delete results when used with search
  24. - otherwise delete all bookmarks
  25. --retain-order prevents reordering after deleting a bookmark
  26. -h, --help show this information and exit
  27. -v, --version show the program version and exit
  28. EDIT OPTIONS:
  29. --url keyword bookmark link
  30. --tag [+|-] [...] comma-separated tags
  31. clear bookmark tagset, if no arguments
  32. '+' appends to, '-' removes from tagset
  33. --title [...] bookmark title; if no arguments:
  34. -a: do not set title, -u: clear title
  35. -c, --comment [...] notes or description of the bookmark
  36. clears description, if no arguments
  37. --immutable N disable web-fetch during auto-refresh
  38. N=0: mutable (default), N=1: immutable
  39. --swap N M swap two records at specified indices
  40. SEARCH OPTIONS:
  41. -s, --sany [...] find records with ANY matching keyword
  42. this is the default search option
  43. -S, --sall [...] find records matching ALL the keywords
  44. special keywords -
  45. "blank": entries with empty title/tag
  46. "immutable": entries with locked title
  47. --deep match substrings ('pen' matches 'opens')
  48. --markers search for keywords in specific fields
  49. based on (optional) prefix markers:
  50. '.' - title, '>' - description, ':' - URL,
  51. '#' - tags (comma-separated, PARTIAL matches)
  52. '#,' - tags (comma-separated, EXACT matches)
  53. '*' - any field (same as no prefix)
  54. -r, --sreg expr run a regex search
  55. -t, --stag [tag [,|+] ...] [- tag, ...]
  56. search bookmarks by tags
  57. use ',' to find entries matching ANY tag
  58. use '+' to find entries matching ALL tags
  59. excludes entries with tags after ' - '
  60. list all tags, if no search keywords
  61. -x, --exclude [...] omit records matching specified keywords
  62. --random [N] output random bookmarks out of the selection (default 1)
  63. --order fields [...] comma-separated list of fields to order the output by
  64. (prepend with '+'/'-' to choose sort direction)
  65. ENCRYPTION OPTIONS:
  66. -l, --lock [N] encrypt DB in N (default 8) # iterations
  67. -k, --unlock [N] decrypt DB in N (default 8) # iterations
  68. POWER TOYS:
  69. --ai auto-import bookmarks from web browsers
  70. Firefox, Chrome, Chromium, Vivaldi, Edge
  71. -e, --export file export bookmarks to Firefox format HTML
  72. export XBEL, if file ends with '.xbel'
  73. export Markdown, if file ends with '.md'
  74. format: [title](url) <!-- TAGS -->
  75. export Orgfile, if file ends with '.org'
  76. format: *[[url][title]] :tags:
  77. export rss feed if file ends with '.rss'
  78. export buku DB, if file ends with '.db'
  79. combines with search results, if opted
  80. -i, --import file import bookmarks from file
  81. supports .html .xbel .json .md .org .rss .db
  82. -p, --print [...] show record details by indices, ranges
  83. print all bookmarks, if no arguments
  84. -n shows the last n results (like tail)
  85. -f, --format N limit fields in -p or JSON search output
  86. N=1: URL; N=2: URL, tag; N=3: title;
  87. N=4: URL, title, tag; N=5: title, tag;
  88. N0 (10, 20, 30, 40, 50) omits DB index
  89. -j, --json [file] JSON formatted output for -p and search.
  90. prints to stdout if argument missing.
  91. otherwise writes to given file
  92. --colors COLORS set output colors in five-letter string
  93. --nc disable color output
  94. -n, --count N show N results per page (default 10)
  95. --np do not show the subprompt, run and exit
  96. -o, --open [...] browse bookmarks by indices and ranges
  97. open a random bookmark, if no arguments
  98. --oa browse all search results immediately
  99. --replace old new replace old tag with new tag everywhere
  100. delete old tag, if new tag not specified
  101. --url-redirect when fetching an URL, use the resulting
  102. URL from following *permanent* redirects
  103. (when combined with --export, the old URL
  104. is included as additional metadata)
  105. --tag-redirect [tag] when fetching an URL that causes permanent
  106. redirect, add a tag in specified pattern
  107. (using 'http:{}' if not specified)
  108. --tag-error [tag] when fetching an URL that causes an HTTP
  109. error, add a tag in specified pattern
  110. (using 'http:{}' if not specified)
  111. --del-error [...] when fetching an URL causes any (given)
  112. HTTP error, delete/do not add it
  113. --export-on [...] export records affected by the above
  114. options, including removed info
  115. (requires --update and --export; specific
  116. HTTP response filter can be provided)
  117. --cached index|URL browse a cached page from Wayback Machine
  118. --offline add a bookmark without connecting to web
  119. --suggest show similar tags when adding bookmarks
  120. --tacit reduce verbosity, skip some confirmations
  121. --nostdin do not wait for input (must be first arg)
  122. --threads N max network connections in full refresh
  123. default N=4, min N=1, max N=10
  124. -V check latest upstream version available
  125. -g, --debug show debug information and verbose logs
  126. SYMBOLS:
  127. > url
  128. + comment
  129. # tags
  130. PROMPT KEYS:
  131. 1-N browse search result indices and/or ranges
  132. R [N] print out N random search results
  133. (or random bookmarks if negative or N/A)
  134. ^ id1 id2 swap two records at specified indices
  135. O [id|range [...]] open search results/indices in GUI browser
  136. toggle try GUI browser if no arguments
  137. a open all results in browser
  138. s keyword [...] search for records with ANY keyword
  139. S keyword [...] search for records with ALL keywords
  140. d match substrings ('pen' matches 'opened')
  141. m search with markers - search string is split
  142. into keywords by prefix markers, which determine
  143. what field the keywords is searched in:
  144. '.', '>' or ':' - title, description or URL
  145. '#'/'#,' - tags (comma-separated, partial/full match)
  146. '*' - all fields (can be omitted in the 1st keyword)
  147. note: tag marker is not affected by 'd' (deep search)
  148. v fields change sorting order (default is '+index')
  149. multiple comma/space separated fields can be specified
  150. r expression run a regex search
  151. t [tag, ...] search by tags; show taglist, if no args
  152. g taglist id|range [...] [>>|>|<<] [record id|range ...]
  153. append, set, remove (all or specific) tags
  154. search by taglist id(s) if records are omitted
  155. n show next page of search results
  156. N show previous page of search results
  157. o id|range [...] browse bookmarks by indices and/or ranges
  158. p id|range [...] print bookmarks by indices and/or ranges
  159. w [editor|id] edit and add or update a bookmark
  160. c id copy URL at search result index to clipboard
  161. ? show this help
  162. q, ^D, double Enter exit buku

Colors

buku supports custom colors. Visit the wiki page on how to customize colors for more details.

Quickstart

  1. Export VISUAL or EDITOR to point to your favourite editor. Note that VISUAL takes precedence over EDITOR.
  2. Create a sweeter shortcut with some convenience.

    1. alias b='buku --suggest'
  3. Auto-import bookmarks from your browser(s). Please quit the relevant browsers beforehand to ensure the databases are not locked.

    1. b --ai
  4. Manually add a bookmark (for hands-on).

    1. b -w
  5. List your bookmarks with DB index.

    1. b -p
  6. For GUI and browser integration (or to sync bookmarks with your favourite bookmark management service) refer to the wiki page on System integration.
  7. Quick (bash/zsh) commands to fuzzy search with fzf and open the selection in Firefox:

    1. firefox $(buku -p -f 10 | fzf)
    2. firefox $(buku -p -f 40 | fzf | cut -f1)

    POSIX script to show a preview of the bookmark as well:

    1. #!/usr/bin/env sh
    2. url=$(buku -p -f4 | fzf -m --reverse --preview "buku -p {1}" --preview-window=wrap | cut -f2)
    3. if [ -n "$url" ]; then
    4. echo "$url" | xargs firefox
    5. fi

Examples

  1. Edit and add a bookmark from editor:

    1. $ buku -w
    2. $ buku -w 'gedit -w'
    3. $ buku -w 'macvim -f' -a https://ddg.gg search engine, privacy

    The first command picks editor from the environment variable EDITOR. The second command opens gedit in blocking mode. The third command opens macvim with option -f and the URL and tags populated in template.

  2. Add a simple bookmark:

    1. $ buku --nostdin -a https://github.com/
    2. 2648. GitHub: Lets build from here · GitHub
    3. > https://github.com/
    4. + GitHub is where over 94 million developers shape the future of software, together. Contribute to the open source community, manage your Git repositories, review code like a pro, track bugs
    5. and features, power your CI/CD and DevOps workflows, and secure code before you commit it.
    6. $ buku --nostdin -a https://github.com/
    7. [ERROR] URL [https://github.com/] already exists at index 2648

    >: URL, +: comment, #: tags

    Title, description and tags will be fetched from site. Buku only stores unique URLs and will raise error if the URL already present in the database:

  3. Add a bookmark with tags search engine and privacy, comment Search engine with perks, fetch page title from the web:

    1. $ buku -a https://ddg.gg search engine, privacy -c Search engine with perks
    2. 336. DuckDuckGo
    3. > https://ddg.gg
    4. + Alternative search engine with perks
    5. # privacy,search engine

    where, >: URL, +: comment, #: tags

  4. Add a bookmark with tags search engine & privacy and immutable custom title DDG:

    1. $ buku -a https://ddg.gg search engine, privacy --title 'DDG' --immutable 1
    2. 336. DDG (L)
    3. > https://ddg.gg
    4. # privacy,search engine

    Note that URL must precede tags.

  5. Add a bookmark without a title (works for update too):

    1. $ buku -a https://ddg.gg search engine, privacy --title
  6. Edit and update a bookmark from editor:

    1. $ buku -w 15012014

    This will open the existing bookmark’s details in the editor for modifications. Environment variable EDITOR must be set.

  7. Update existing bookmark at index 15012014 with new URL, tags and comments, fetch title from the web:

    1. $ buku -u 15012014 --url http://ddg.gg/ --tag web search, utilities -c Private search engine
  8. Fetch and update only title for bookmark at 15012014:

    1. $ buku -u 15012014
  9. Update only comment for bookmark at 15012014:

    1. $ buku -u 15012014 -c this is a new comment

    Applies to —url, —title and —tag too.

  10. Export bookmarks tagged tag 1 or tag 2 to HTML, XBEL, Markdown, Orgfile or a new database:

    $ buku -e bookmarks.html —stag tag 1, tag 2
    $ buku -e bookmarks.xbel —stag tag 1, tag 2
    $ buku -e bookmarks.md —stag tag 1, tag 2
    $ buku -e bookmarks.org —stag tag 1, tag 2
    $ buku -e bookmarks.db —stag tag 1, tag 2
    All bookmarks are exported if search is not opted.

  11. Import bookmarks from HTML, XBEL, Markdown or Orgfile:

    1. $ buku -i bookmarks.html
    2. $ buku -i bookmarks.xbel
    3. $ buku -i bookmarks.md
    4. $ buku -i bookmarks.org
    5. $ buku -i bookmarks.db
  12. Delete only comment for bookmark at 15012014:

    1. $ buku -u 15012014 -c

    Applies to —title and —tag too. URL cannot be deleted without deleting the bookmark.

  13. Update or refresh full DB with page titles from the web:

    1. $ buku -u
    2. $ buku -u --tacit (show only failures and exceptions)

    This operation can update the title or description fields of non-immutable bookmarks by parsing the fetched page. Fields are updated only if the fetched fields are non-empty. Tags remain untouched.

  14. Delete bookmark at index 15012014:

    1. $ buku -d 15012014
    2. Index 15012020 moved to 15012014

    The last index is moved to the deleted index to keep the DB compact. Add --tacit to delete without confirmation.

  15. Delete all bookmarks:

    1. $ buku -d
  16. Delete a range or list of bookmarks:

    1. $ buku -d 100-200
    2. $ buku -d 100 15 200
  17. Search bookmarks for ANY of the keywords kernel and debugging in URL, title or tags:

    1. $ buku kernel debugging
    2. $ buku -s kernel debugging
  18. Search bookmarks with ALL the keywords kernel and debugging in URL, title or tags:

    1. $ buku -S kernel debugging
  19. Search bookmarks tagged general kernel concepts:

    1. $ buku --stag general kernel concepts
  20. Search for bookmarks matching ANY of the tags kernel, debugging, general kernel concepts:

    1. $ buku --stag kernel, debugging, general kernel concepts
  21. Search for bookmarks matching ALL of the tags kernel, debugging, general kernel concepts:

    1. $ buku --stag kernel + debugging + general kernel concepts
  22. Search for bookmarks matching any of the keywords hello or world, excluding the keywords real and life, matching both the tags kernel and debugging, but excluding the tags general kernel concepts and books:

    1. $ buku hello world --exclude real life --stag 'kernel + debugging - general kernel concepts, books'
  23. Search for bookmarks with different tokens for each field, and print them out sorted by the tags (ascending) and URL (descending)

    1. $ buku --order +tags,-url --markers --sall 'global substring' '.title substring' ':url substring' :https '> description substring' '#partial,tags:' '#,exact,tags' '*another global substring'
  24. List all unique tags alphabetically:

    1. $ buku --stag
  25. Run a search and update the results:

    1. $ buku -s kernel debugging -u --tag + linux kernel
  26. Run a search and delete the results:

    1. $ buku -s kernel debugging -d
  27. Encrypt or decrypt DB with custom number of iterations (15) to generate key:

    1. $ buku -l 15
    2. $ buku -k 15

    The same number of iterations must be specified for one lock & unlock instance. Default is 8, if omitted.

  28. Show details of bookmarks at index 15012014 and ranges 20-30, 40-50:

    1. $ buku -p 20-30 15012014 40-50
  29. Show details of the last 10 bookmarks:

    1. $ buku -p -10
  30. Show all bookmarks with real index from database:

    1. $ buku -p
    2. $ buku -p | more
  31. Replace tag ‘old tag’ with ‘new tag’:

    1. $ buku --replace 'old tag' 'new tag'
  32. Delete tag ‘old tag’ from DB:

    1. $ buku --replace 'old tag'
  33. Append (or delete) tags ‘tag 1’, ‘tag 2’ to (or from) existing tags of bookmark at index 15012014:

    1. $ buku -u 15012014 --tag + tag 1, tag 2
    2. $ buku -u 15012014 --tag - tag 1, tag 2
  34. Open URL at index 15012014 in browser:

    1. $ buku -o 15012014
  35. List bookmarks with no title or tags for bookkeeping:

    1. $ buku -S blank
  36. List bookmarks with immutable title:

    1. $ buku -S immutable
  37. Append, remove tags at prompt (taglist index to the left, bookmark index to the right):

    1. // append tags at taglist indices 4 and 6-9 to existing tags in bookmarks at indices 5 and 2-3
    2. buku (? for help) g 4 9-6 >> 5 3-2
    3. // set tags at taglist indices 4 and 6-9 as tags in bookmarks at indices 5 and 2-3
    4. buku (? for help) g 4 9-6 > 5 3-2
    5. // remove all tags from bookmarks at indices 5 and 2-3
    6. buku (? for help) g > 5 3-2
    7. // remove tags at taglist indices 4 and 6-9 from tags in bookmarks at indices 5 and 2-3
    8. buku (? for help) g 4 9-6 << 5 3-2
  38. List bookmarks with colored output:

    1. $ buku --colors oKlxm -p
  39. Add a bookmark after following all permanent redirects, but only if the server doesn’t respond with an error (and there’s no network failure)

    1. $ buku --add http://wikipedia.net --url-redirect --del-error
    2. 2. Wikipedia
    3. > https://www.wikipedia.org/
    4. + Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.
  40. Add a bookmark with tag http redirect if the server responds with a permanent redirect, or tag shaped like http 404 on an error response:

    1. $ buku --add http://wikipedia.net/notfound --tag-redirect 'http redirect' --tag-error 'http {}'
    2. [ERROR] [404] Not Found
    3. 3. Not Found
    4. > http://wikipedia.net/notfound
    5. # http 404,http redirect
  41. Update all bookmarks matching the search by updating the URL if the server responds with a permanent redirect, deleting the bookmark if the server responds with HTTP error 400, 401, 402, 403, 404 or 500, or adding a tag shaped like http:{} in case of any other HTTP error; then export those affected by such changes into an HTML file, marking deleted records as well as old URLs for those replaced by redirect.

    1. $ buku -S ://wikipedia.net -u --url-redirect --tag-error --del-error 400-404,500 --export-on --export backup.html
  42. Print out a single random bookmark:

    1. $ buku --random --print
  43. Print out 3 random bookmarks ordered by netloc (reversed), title and url:

    1. $ buku --random 3 --order ,-netloc,title,+url --print
  44. Print out a single random bookmark matching search criteria, and export into a Markdown file (in DB order):

    1. $ buku --random -S kernel debugging --export random.md
  45. Swap positions of records #4 and #5:

    1. $ buku --swap 4 5
  46. More help:

    1. $ buku -h
    2. $ man buku

Automation

Interactive workflows can be automated using expect. Issue #368 has a working example on automating auto-import.

Troubleshooting

Editor integration

You may encounter issues with GUI editors which maintain only one instance by default and return immediately from other instances. Use the appropriate editor option to block the caller when a new document is opened. See issue #210 for gedit.

Collaborators

Copyright © 2015-2025 Arun Prakash Jana

gitter chat

Contributions

Missing a feature? There’s a rolling ToDo List with identified tasks. Contributions are welcome! Please follow the PR guidelines.

See also our documentation here Stable Docs

  • bukubrow, WebExtension for browser integration
  • oil, search-as-you-type cli front-end
  • buku_run, rofi front-end
  • pinku, a Pinboard-to-buku import utility
  • buku-dmenu, a simple bash dmenu wrapper
  • poku, sync between Pocket and buku
  • Ebuku, Emacs interface to buku
  • diigoku, buku importer for Diigo
  • BukuBot, Chat bot for XMPP with an extended visual interface

Videos

In the Press