Commit 8ff2d512 authored by adam j hartz's avatar adam j hartz

bookmark: add option to list all bookmarks

parent 550f2a37
......@@ -53,8 +53,19 @@ def _load_bookmarks(args, stdin=None):
with open(fname) as f:
PLUGIN_SETTINGS.data = json.load(f)
def _list_bookmarks(args, stdin=None):
if len(args) > 0:
return None, 'Error: too many arguments\n', 1
leftside_len = max(len(i) for i in PLUGIN_SETTINGS.data) + 2
out = ''
for k, v in sorted(PLUGIN_SETTINGS.data.items()):
out += '%s \033[0;36m%s\033[0m %s\n' % (k, '.' * (leftside_len-len(k)), v)
return out, '', int(bool(out))
PLUGIN_SETTINGS.aliases['bmark'] = _add_bookmark
PLUGIN_SETTINGS.aliases['bgo'] = _follow_bookmark
PLUGIN_SETTINGS.aliases['bwrite'] = _write_bookmarks
PLUGIN_SETTINGS.aliases['bload'] = _load_bookmarks
PLUGIN_SETTINGS.aliases['blist'] = _list_bookmarks
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment