Skip to content
This repository was archived by the owner on Feb 22, 2022. It is now read-only.
/ cli-bookmarks Public archive

Bookmark filesystem locations and access them in a fast and easy way

License

Notifications You must be signed in to change notification settings

DavidGamba/cli-bookmarks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8556ad0 · Feb 22, 2022

History

9 Commits
Aug 26, 2019
Aug 26, 2019
Aug 26, 2019
Jan 4, 2018
Jan 4, 2018
Aug 26, 2019
Jan 4, 2018
Aug 26, 2019
Jan 4, 2018
Jan 4, 2018
Feb 22, 2022
Jan 4, 2018
Jun 14, 2020
Aug 26, 2019
Aug 26, 2019
Jan 4, 2018
Aug 26, 2019
Aug 26, 2019

Repository files navigation

cli-bookmarks cli-bookmarks: CLI Filesystem Directory Bookmarks

cli-bookmarks is yet another tool to bookmark filesystem locations and access them in a fast and easy way.

Important

Features:

  • Easy bash completion setup. The completions are generated by the tool in a high level language, not in bash.

  • Both termbox based UI and CLI only modes.

  • Bookmarks are stored on an easy to edit toml file.

SYNOPSIS

# Show the GUI
cb

# Use a bookmark
cb bookmark_alias

# Use a bookmark and navigate its subdirectories
cb bookmark_alias <tab>

# Use a bookmark with an alternate config file
cb --file /abs/path/to/alternate/config/file bookmark_alias

Bookmarks are stored by default in the ~/.cli-bookmarks.toml file.

Setup

Add the following to your bash setup:

function cb() {
  local out=""
  local exit_value=1
  if [[ $# -eq 0 ]]; then
    out=`cli-bookmarks`
    exit_value=$?
  else
    out=`cli-bookmarks "$*"`
    exit_value=$?
  fi
  if [[ $exit_value == 0 ]]; then
    cd "$out"
  else
    echo "$out"
  fi
}

function _cliBookmarks() {
  COMPREPLY=(`cli-bookmarks --completion-current ${2} --completion-previous ${3}`)
  return 0
}
complete -o filenames -o nospace -F _cliBookmarks cb

Install

Using GOLANG:

go install github.com/DavidGamba/cli-bookmarks

Or grab one of the generated artifacts from the Releases page.

Configuration file

Bookmarks are stored by default in the ~/.cli-bookmarks.toml file. The file syntax is described below:

[bookmarks] # (1)
alias = "/full/path/to/dir" (2)
  1. The [bookmarks] table (also known as hash table or dictionary) is where all the aliases are placed.

  2. The key/value alias combination. The value is a string (must be surrounded in quotes) with the full path of a directory.

The precedence to determine the configuration file is as follows:

  1. The --file /abs/path/to/conf/file command line flag.

  2. The build variable ConfigFilePath. Build using:

    go build -ldflags="-X main.ConfigFilePath=/abs/path/to/conf/file"

  3. The default configuration file path: $HOME/.cli-bookmarks.toml

ROADMAP

  • Completion results don’t need to include the alias. In bash:

    cd ~/code <tab>
    games/
    tools/
    tutorials/

    vs:

    cb alias <tab>
    alias/games/
    alias/tools/
    alias/tutorials/
  • Add add command to add CWD to the bookmarks file.

  • Sort aliases in GUI.

  • Add another section for common files and pass that to an EDITOR.

  • If there are too many bookmarks, the GUI will clip them and only show the ones it can display.

  • Support mouse double click in GUI to select entry.

  • Support tab in GUI.

LICENSE

This file is part of cli-bookmarks.

Copyright © 2018 David Gamba Rios

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.