Buku: A Book­mark Man­ager in the Com­mand Line

Man­ag­ing book­marks is an im­por­tant as­pect of im­prov­ing our ex­pe­ri­ence on the Web. When used ju­di­ciously, book­marks can save us a lot of time, ef­fort and re­sources. This ar­ti­cle fa­mil­iarises read­ers with Buku, a com­mand line book­mark man­ager.

OpenSource For You - - Contents - By: Mag­i­mai Prakash The au­thor has a B.E. de­gree in com­puter sci­ence. As he is deeply in­ter­ested in Linux, he spends most of his leisure time ex­plor­ing open source.

Book­marks are like short­cuts to Web pages. Browsers are ad­e­quate when it comes to book­marks but to ac­cess the lat­ter again, you have to open your browser. There’s no in­de­pen­dent so­lu­tion for book­marks that pro­tects your pri­vacy and safe­guards your data, which is why you need to try Buku.

Buku is a light­weight and flex­i­ble book­mark man­ager that comes with a com­mand line in­ter­face (CLI). It pos­sesses all the nec­es­sary func­tion­al­i­ties of the typ­i­cal book­mark man­ager and it also has some unique fea­tures like be­ing self-hosted, hav­ing man­ual en­cryp­tion sup­port, the ca­pa­bil­ity to shorten and ex­pand URLs; the auto im­port of book­marks from Fire­fox, Google Chrome and Chromium; au­to­matic up­dates of the book­marks, in­te­grated text ed­i­tor sup­port for adding the book­marks, and much more.

In this ar­ti­cle, we’re go­ing to see how Buku works its magic through the CLI in Linux, but if you pre­fer a GUI ver­sion of Buku, the GUI in­te­gra­tion is ex­plained in its GitHub project page.

In­stal­la­tion

Let’s in­stall Buku in De­bian based sys­tems. Be­fore in­stal­la­tion, take a look at some of the sys­tem re­quire­ments.

Buku is a Python based pack­age; so let’s use the PythonPip pack­age to in­stall the nec­es­sary pack­ages.

As I pre­fer Python3, let’s use the Python-pip3 pack­age, which won’t be avail­able in the sys­tem by de­fault; so you’ll have to in­stall this pack­age man­u­ally us­ing the fol­low­ing com­mand:

$sudo apt-get in­stall python3-pip

Once you’re done, use Python-pip3 to in­stall the fol­low­ing pack­ages in the sys­tem:

$sudo pip3 in­stall url­lib3 cryp­tog­ra­phy beau­ti­ful­soup4 re­quests

Af­ter com­ple­tion, pro­ceed with the Buku in­stal­la­tion by adding the Buku PPA by us­ing the fol­low­ing com­mand:

$sudo add-apt-repos­i­tory ppa:twodope­shaggy/jarun Now up­date the sys­tem, as fol­lows: $sudo apt-get up­date

Fi­nally, in­stall the Buku pack­age with the com­mand shown be­low:

$sudo apt-get in­stall buku

The ba­sics

Each book­mark in Buku con­tains the fol­low­ing four parts:

URL

Ti­tle

Tags

Com­ments

URL: This holds the ad­dress of the par­tic­u­lar Web page that you want to book­mark. Do note that all the URLs are unique in Buku, and if your URL con­tains spe­cial char­ac­ters such as ‘;’, ‘,’, ‘&’ and ‘()’ please en­close such URLs with sin­gle or dou­ble quotes, so that spe­cial char­ac­ters in the URL don’t get in­ter­preted by the shell.

Ti­tle: A ti­tle is op­tional in Buku be­cause as soon as you have added a book­mark in Buku, it will au­to­mat­i­cally fetch the ti­tle from the URL through the Web and in­sert it into the cor­re­spond­ing book­mark. But if you want to set the ti­tle by your­self, you can use the –ti­tle op­tion to do so.

By de­fault, all the ti­tles are change­able (N=0), but if you want to make a ti­tle con­stant, you can set the ti­tle im­mutable value (N=1).

Tags: These are es­sen­tial in Buku be­cause, through their ef­fec­tive use, book­marks can be iden­ti­fied, searched and linked with other rel­e­vant book­marks. Buku uses the comma to sep­a­rate tags, so you can­not place a comma within a tag.

Com­ments: Com­ments are ad­di­tional in­for­ma­tion you give to the book­marks for your own con­ve­nience. These can be changed any­time you wish. Com­ments can be brief and unique so that each book­mark can be recog­nised eas­ily.

Buku stores all the book­marks in a sin­gle data­base file. Each URL is unique in the data­base. Be­sides, book­marks are ac­cessed through their in­dex in the data­base. So when­ever we want to add, delete or up­date book­marks, we need to pro­vide the in­dex of the book­mark in the data­base.

Adding a book­mark

To add a book­mark, you need to use the (-a) op­tion along with the Buku com­mand, fol­lowed by the URL, tags and com­ments.

For ex­am­ple, the fol­low­ing com­mand will add a book­mark on the Wikipedia page for ‘Free Soft­ware’:

$buku -a https://en.wikipedia.org/wiki/Free_­soft­ware wiki,free_­soft­ware,wikipedia -c Wikipedia ar­ti­cle on Free Soft­ware

In the above ex­am­ple, we can see the URL of the Wikipedia page that we want to book­mark. Af­ter that, we have tags as ‘wiki’, ‘free_­soft­ware’ and ‘wikipedia’ sep­a­rated by the comma and fi­nally, the ‘-c’ op­tion will show the com­ment for the book­mark.

Fig­ure 1 il­lus­trates the out­put in the ter­mi­nal af­ter the book­mark has been suc­cess­fully added to the Buku data­base.

If you’re un­com­fort­able with this struc­ture, you can add your book­marks us­ing the ed­i­tor with the ‘-w’ op­tion, as shown be­low:

$buku -w ‘nano-w’

The above com­mand will open the nano ed­i­tor along with the skele­ton struc­ture for adding a book­mark. All you need to do is fill in the blanks in the ed­i­tor and save it.

Up­dat­ing a book­mark

We can up­date a book­mark by us­ing the (-u) op­tion. Buku is so flex­i­ble that even in­di­vid­ual el­e­ments of the book­mark can be up­dated sep­a­rately while the oth­ers re­main in­tact.

For each up­date, you need to pro­vide the in­dex of that book­mark. If you’re not sure of the in­dex num­ber of the book­marks, you can view all the book­marks along with their in­dex num­bers by us­ing the fol­low­ing com­mand:

$buku -p For in­stance, if a web­site has changed its name, we can

up­date our book­mark to use the site’s most re­cent name from the Web, by us­ing the fol­low­ing com­mand:

$buku -u 2

In the above com­mand, the num­ber ‘2’ de­notes the in­dex of the book­mark in the data­base.

If you pre­fer only to up­date the com­ment of a par­tic­u­lar book­mark, you can use the ‘-c’ op­tion along with the up­dated com­ment.

The com­ment sec­tion of the Wikipedia ar­ti­cle that was added ear­lier can be up­dated by us­ing the fol­low­ing com­mand:

$buku -u 7 -c this a Wikipedia ar­ti­cle on Free Soft­ware

Sim­i­larly, you can up­date the URL, ti­tle and tags with any one of the op­tions ‘--url’, ‘--ti­tle’ and ‘--tags’, along with their rel­e­vant data.

Delet­ing a book­mark

To delete a book­mark, you need to use the -d op­tion along with its in­dex num­ber, as shown be­low:

$buku -d 5

The above com­mand will delete the book­mark in In­dex 5 and the last book­mark will take the deleted book­mark’s place so that no void space ex­ists in the data­base.

To delete all the book­marks, no in­dex num­bers are to be given:

$buku -d

If you want to delete book­marks from a spe­cific range, pro­vide the range as an ar­gu­ment, as fol­lows:

$buku -d 5 10

Search­ing

To search for a book­mark, you can use tags as your pri­mary source, be­cause as long as your tags are rel­e­vant to your book­marks, they will help you greatly in find­ing the rel­e­vant book­marks.

$buku --stag pri­vacy, search_engine

The above com­mand will list the book­marks that have ei­ther ‘pri­vacy’ or ‘search en­gine’ in their tags. You can re­fine your search by mak­ing all the tag in­puts match a book­mark.

$buku --stag pri­vacy + search_engine

You can also run a search based on the key­words of the book­marks.

$buku -S pri­vacy search_engine

The above com­mand will list the book­marks that have a match for the key­words ‘pri­vacy’ and ‘search_engine’ in their URL, tags and com­ments.

If you want to search book­marks with any one of the key­words match­ing words in the URL, tags, and com­ments, use the fol­low­ing com­mand:

$buku -s pri­vacy search_engine

En­cryp­tion

En­cryp­tion is an im­por­tant fea­ture of Buku, since all the book­marks are con­trolled and main­tained by the user it­self. En­cryp­tion makes sure that only au­tho­rised per­son­nel ac­cess the book­marks so that the pri­vacy and in­tegrity of the book­marks re­main pris­tine.

Buku uses the AES256 al­go­rithm for en­crypt­ing the data­base but to use en­cryp­tion, first the data­base needs to be locked by sup­ply­ing a pass­word of your choice.

$buku -l

The above com­mand will ask for a pass­word to lock the data­base. Once you sup­ply the pass­word, you will see that

the file is en­crypted. When you try to view the book­marks, you will get an er­ror mes­sage that the data­base needs to be un­locked first.

To de­crypt the data­base file, you need to is­sue the com­mand with the op­tion -k so that you can ac­cess the book­mark data­base, as shown be­low:

$buku -k

Af­ter you have pro­vided the right pass­word, you will see the data­base is de­crypted.

Please note that af­ter de­cryp­tion, the book­mark data­base will re­main in the un­en­crypted state, so please lock the data­base when not in use.

Im­port­ing and ex­port­ing

Buku sup­ports HTML, Mark­down and DB for­mats for im­port­ing and ex­port­ing book­marks. And you can ex­port all the book­marks to one of the sup­ported for­mats by us­ing the ‘-e’ op­tion.

$buku -e book­marks.html

The above com­mand will ex­port the book­marks in the HTML for­mat.

If you want to ex­port only spe­cific book­marks from Buku, you can use tags. That way, only the book­marks that have those par­tic­u­lar tags get ex­ported.

For ex­am­ple, if you want to ex­port the book­marks that have the tags ‘pri­vacy’, you may mod­ify the above com­mand as fol­lows:

$buku -e book­marks.html --tag pri­vacy

For im­port­ing book­marks, you can ei­ther use the au­to­matic im­port op­tion to im­port all the book­marks from your browser, or you can im­port the book­marks from one of the sup­ported for­mats men­tioned in the above sec­tions.

To use the au­to­matic im­port, use --ai along with the Buku com­mand, as shown be­low:

$buku --ai

You will be asked if the par­ent folder from the browser can be used for tags; choose the ‘Yes’ or ‘No’ op­tion, as you wish.

The next ques­tion will be: Which browser can be used to im­port book­marks? For ex­am­ple, I have Google Chrome and Fire­fox on my sys­tem. I wish to im­port book­marks from Chrome, so I will give the re­sponse ‘y’ to Chrome, af­ter which it will im­port the book­marks from Google Chrome and add them to the Buku data­base.

To man­u­ally im­port the book­marks from HTML or any of the sup­ported for­mats, use the fol­low­ing com­mand: $buku -i book­mark­s_fr­m_chrome.html

Based on your re­sponses to the ques­tions, the book­marks will be added in the Buku data­base.

Do note that in both cases, auto-gen­er­ated tags will be in­cor­po­rated in the book­marks, but you can al­ways change the tags or com­ments via the up­date op­tion.

Short­en­ing and ex­pand­ing URLs

Buku can shorten a URL by ex­plic­itly sup­ply­ing it as an ar­gu­ment. You can also use the in­dex of a book­mark you want to shorten. By de­fault, Buku uses the tny.im URL short­en­ing ser­vice to shorten URLs.

For ex­am­ple, if you want to shorten the URL of the Wikipedia ar­ti­cle ‘https://en.wikipedia.org/wiki/Bat­tle_ of_War­saw_(1920)’, as men­tioned ear­lier, if any spe­cial char­ac­ters are in­cluded in the URL, do re­mem­ber to en­close them within the quotes.

$buku --shorten ‘https://en.wikipedia.org/wiki/Bat­tle_of_ War­saw_(1920)’

The above method will work if you sup­ply the in­dex num­ber of a book­mark in­stead of the URL.

In the same way, we can ex­pand the URL by us­ing the --ex­pand op­tion and sup­ply­ing the tiny.im URL as an ar­gu­ment:

$buku --ex­pand http://tny.im/xO0us

Fig­ure 5: Search one key­word

Fig­ure 4: Search all key­words

Fig­ure 3: Book­mark view all

Fig­ure 2: Book­mark ed­i­tor

Fig­ure 1: Book­mark added out­put

Fig­ure 7: File de­crypted

Fig­ure 6: File en­crypted

Fig­ure 8: Shor­t­end URL

Newspapers in English

Newspapers from India

© PressReader. All rights reserved.