Update 1.9.2023: Reimplemented in Rust: 20x faster bkmr
** Please switch to the Rust version. It is worth it. **
Generic URI manager for the command line.
Features:
- full-text search across URIs, manages URIs in sqlite FTS database
- knows how to open HTTP URLs, directories, files (e.g. Office, Images, ....)
- can execute URIs as shell commands via the protocol prefix: 'shell::'
URI-Example:
shell::vim +/"## SqlAlchemy" $HOME/document.md
- tags for URI classification
- check tags for consistency when adding new bookmark
- pipe search results downstream for collective action, e.g. update, open, ...
- open group of URIs non-interactively, e.g. open all URIs regarding Poker simultaneously
Inspired by https://github.com/jarun/buku. If you are happy using buku, by all means stick with it. It is battle tested.
twbm is 100% buku compatible. Switch back and forth between twbm and buku is possible without data loss.
To harness twbm
's power use full-text query syntax (see: https://www.sqlite.org/fts5.html chapter 3).
Two complementary commands are provided:
- twbm: CLI tool with FTS for generic URI management
- twbuku: 100% buku with small enhancements and usage of an enhanced database
Getting help: twbm --help
# FTS examples (https://www.sqlite.org/fts5.htm)
twbm search 'security "single-page"'
twbm search '"https://securit" *'
twbm search '^security'
twbm search 'postgres OR sqlite'
twbm search 'security NOT keycloak'
# FTS combined with tag filtering
twbm search -t tag1,tag2 -n notag1 <searchquery>
# Match exact taglist
twbm search -e tag1,tag2
# Open all matching sites non-interactively
twbm search poker --np | twbm open
# Search -> select interactively -> pipe bookmark id downstream for processing
twbm search xxxxx | twbm update -t x
# Search by any tag and sort by bookmark age ascending
twbm search -T tag1,tag2 -O
# Adding URI to local files
twbm add /home/user/presentation.pptx tag1,tag2 --title 'My super Presentation'
twmb add '$HOME/vimwiki/e4m/poker-points.png' --title 'Poker Points'
# Adding shell commands as URI
twbm add "shell::vim +/'# SqlAlchemy' sql.md" shell,sql,doc --title 'sqlalchemy snippets'
Tags must be separated by comma without blanks. When adding a generic URI, which is not starting with 'http', the cli message 'Malformed URL' can be ignored.
Selection of multiple bookmarks for opening in browser is possible, of course:
After selection the program ends and returns to the command line prompt.
pipx twbm
Database schema upgrade:
- To upgrade existing buku-db:
twbm-upgrade-db.sh buku.db twbm.db
. - To downgrade twbm-db:
twbm-downgrade-db.sh twbm.db buku.db
.
All transactions do not affect existing databases.
Tested configuration:
- sqlite 3.36.0 (requires update on macOS)
- macOS 10.15.7
Location of sqlite database:
# aliases which I use
alias b="twbuku --db $HOME/bm.db -n 1000 --deep" # using patched original buku
alias bb="TWBM_DB_URL=sqlite:////$HOME/bm.db twbm search" # using extended CLI tool
alias bbb="TWBM_DB_URL=sqlite:////$HOME/bm.db twbm"
twbm uses a few buku
functions in the background, but is generally rebuilt on top of:
This should make it easy to extend and add functionality in an object-oriented manner.
- download
buku
and compare withbuku.py
- update
buku.py
:# tw: add title tagging
(customization: search for# tw
) - GOTCHA: Exclude
buku.py
fromblack
rm buku
wget https://raw.githubusercontent.com/jarun/buku/master/buku .
black buku
diff buku.py buku
- install twbm with pipx for local development:
pipx install ~/dev/py/twbm
, viamake install
- uninstall:
pipx uninstall twbm
make test
Pycharm run configuration interferes with piping. Testing/Running only possible on CLI.
This affects the following commands: open, update
dev/py/twbm/sql/fts.db vimwiki/buku/bm.db
- github actions sqlite FTS5 module not working proberly, so builds are failing