Rust-Goto v0.3.0: goto — A simple and user-friendly way to jump to your indexed directories.

goto (gt)

CI Status Crates.io License: MIT

gt is a simple and user-friendly way to jump to your indexed directories.

gt is short for "goto", which is basically what you want to do with minimal keystrokes.

Features

  • Convenient syntax gt XXX to jump to XXX's path
  • Easy indexing of sub-directories by using gt add -a
  • Pretty tree-like index listing using gt ls

Demo

Demo

Installation

Step 1. Getting the binary

wget https://github.com/slai11/goto/releases/download/v0.2.4/goto-rs-v0.2.4-x86_64-apple-darwin.tar.gz
tar -xvf goto-rs-v0.2.4-x86_64-apple-darwin.tar.gz 
cp goto-rs-v0.2.4-x86_64-apple-darwin/goto-rs /usr/local/bin

Or you could clone the project and build from source. You will need rust (brew install rust) to do so.

git clone https://github.com/slai11/goto.git
cd goto 
cargo build --release
cp target/release/goto-rs /path/to/modules/

Step 2. Setting up your bash/zsh Paste eval "$(goto-rs init)" in your bashrc or zshrc.

The binary's name is goto-rs while the command you should be using is gt.

A shell-based workaround inspired by https://github.com/ajeetdsouza/zoxide and https://github.com/gsamokovarov/jump is used as it is not possible to change the working directory of your shell programmatically. The awkward naming of the binary is due to lack of namespace.

Coming Soon: Brew install!

Command-Line Options

❯ gt help
gt

USAGE:
    goto-rs [name]... [SUBCOMMAND]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

ARGS:
    <name>...    Refers to name of index. Must be specific for now.

SUBCOMMANDS:
    add      Add directories and sub-directories to index.
    help     Prints this message or the help of the given subcommand(s)
    init     Initialises bash-script and database.
    ls       List all indexed directories.
    prune    Removes invalid indexes in the database.
    rm       Remove directories and sub-directories to index.

Guide

Jumping to an indexed directory

Use gt <PATH> to jump to your desired folder. The <PATH> is the folder name. For example to jump to Users/xxx/project/personal, the command gt personal will change your shell directory to the desired path.

Indexing a directory

To add the current working directory into your indexs:

gt add

To add the current directory with its subdirectories (-a for all subdirectories):

gt add -a

To add multiple levels of subdirectory, use the following command, where n is the levels of subdirectories to add.

gt add -r n

List indexed directories

If you wish to list and inspect your current indexed directories.

gt ls

Cleaning up index to ensure all paths are valid

Use gt prune to update and remove non-existent directories.

Removing indexes

Removing indexes works the same way as gt add but in the reverse manner.

To remove the directory you are in from the indexes:

gt rm

To remove the current directory with its subdirectories:

gt rm -a

To add multiple levels of subdirectory, use the following command, where n is the levels of subdirectories to add.

gt rm -r n

Comments

  • Configurable index db path using envvar
    Configurable index db path using envvar

    Apr 27, 2020

                                                                                                                                                                                                            feat 
    Reply
  • font color doesn't reset predictably
    font color doesn't reset predictably

    Aug 5, 2020

    I installed v0.3.0 from crates.io using rustc 1.45.1 (c367798cf 2020-07-26)

    You can see in this image that after I ran goto-rs ls that the font color of the terminal stayed blue until after I ran ls.

    ``

    image

    Reply
  • Deprecation messages related to 'home_dir'
    Deprecation messages related to 'home_dir'

    Aug 6, 2020

    These warnings could probably be fixed using the dirs crate. I use dirs for one of my projects at https://github.com/theimpossibleastronaut/oxi-rmw/blob/b1c90d8450e74fbec4a56a8f732d73075574ad3c/src/main.rs#L8

    [email protected]:~/src/rust/goto$ cargo clippy
    warning: use of deprecated item 'std::env::home_dir': This function's behavior is unexpected and probably not what you want. Consider using a crate from crates.io instead.
      --> src/db.rs:17:11
       |
    17 |     match env::home_dir().map(|p| format!("{}/{}", p.display(), ".config/goto")) {
       |           ^^^^^^^^^^^^^
       |
       = note: `#[warn(deprecated)]` on by default
    
    warning: use of deprecated item 'std::env::home_dir': This function's behavior is unexpected and probably not what you want. Consider using a crate from crates.io instead.
      --> src/db.rs:41:11
       |
    41 |     match env::home_dir().map(|p| format!("{}/{}", p.display(), ".config/goto/db.txt")) {
       |           ^^^^^^^^^^^^^
    
    
    Reply
  • doc: update doc w download and demo
    doc: update doc w download and demo

    Apr 26, 2020

                                                                                                                                                                                                            size/M doc 
    Reply
  • fix(init): create folder if not exists
    fix(init): create folder if not exists

    Apr 27, 2020

                                                                                                                                                                                                            size/S fix 
    Reply
  • Fix  rm arg
    Fix rm arg

    Apr 27, 2020

                                                                                                                                                                                                            size/S fix 
    Reply
  • refactor: misc cleanup
    refactor: misc cleanup

    Apr 28, 2020

    This PR includes formatting, better error messages and cleaning up rust compiler warnings.

    size/S refactor 
    Reply
  • doc: update changelog for 0.2.4 release
    doc: update changelog for 0.2.4 release

    May 1, 2020

                                                                                                                                                                                                            size/M doc 
    Reply
  • feat(goto): order by inter-char distance
    feat(goto): order by inter-char distance

    Jun 27, 2020

    Use a new distance measure. Calculate distance between position of each found character. This allows for more relevant searches to be selected instead of the shortest alias.

    feat size/M 
    Reply
  • doc(release): release 0.3.0
    doc(release): release 0.3.0

    Jun 29, 2020

                                                                                                                                                                                                            size/S doc 
    Reply
  • fix: various warnings produced by `cargo clippy`
    fix: various warnings produced by `cargo clippy`

    Aug 6, 2020

                                                                                                                                                                                                           
    Reply
  • Allow for manual removal of directories
    Allow for manual removal of directories

    Apr 20, 2020

    This feature seems like a natural requirement, a gt rm of sorts.

    feat 
    Reply
  • app.rs: fix (add) version output (fixes #32)
    app.rs: fix (add) version output (fixes #32)

    Aug 5, 2020

                                                                                                                                                                                                           
    Reply