Giter Site home page Giter Site logo

fuzzycd's Introduction

A bash function that patches the native cd to allow changing directories instantly using a fuzzy search

Fuzzy CD

Version Build Status

Features

  • Preserves the native cd completion.
  • Understands CDPATH.
  • Remembers all visited directories.
  • Allows changing directory to any directory from the history that matches the input fuzzy search (unless it matches an actual directory).
  • Shows available choices, with ls preview, when there are more than one matches (optional).
  • Does not override the builtin cd when running non-interactively.
  • Adds flags such as cd -l to view and manage the history.
  • Interactive menu is optional and can be disabled in favor of "cd to best match".

Prerequisites

Fuzzy CD requires a recent version of fzf.

Installation

Installing using the setup script

This setup script will download the fuzzycd function to /usr/local/bin and apply the necessary source command to your startup script.

$ curl -Ls get.dannyb.co/fuzzycd/setup | bash

You are encouraged to inspect the setup script before running.

Installing manually

  1. Place the fuzzycd file in /usr/local/bin/ and make it executable
  2. Source it (source /usr/local/bin/fuzzycd) from your startup script (for example: ~/.bashrc)

Usage

Show Usage Patterns
$ cd -h

fuzzycd 0.2.2

Usage:
  cd DIR       change working directory
  cd SEARCH    change working directory or show selection menu
  cd -l        list history with fzf
  cd -e        edit history file
  cd -s        show history file
  cd -d [DIR]  delete current or specified directory from history
  cd -v        show version
  cd -h        show this help

Environment Variables:
  FUZZYCD_HISTORY_FILE
    Path to history file (default: ~/.fuzzycd-history)

  FUZZYCD_MODE
    Set operation mode (one of: m, i, p)
      m = minimal, non interactive, always cd to best match
      i = interactive when needed, no preview
      p = interactive when needed, with ls preview (default)

Interactive Keyboard Bindings:
  Del
    Delete selected directory from history

First, verify that Fuzzy CD is properly installed by running:

$ cd -h

Now, you can use cd normally to change to any directory. These directories will be remembered in a history file. You can view this file by running:

$ cd -s
# or
$ cat ~/.fuzzycd-history

Fuzzy search

Use cd with a string that is not a directory. If exactly one directory in the history matches this string, you will instantly cd to it as usual.

If more than one directories match, you will be prompted to choose one of the matching directories when running in interactive mode (default), or you will cd to the best match when running in non-interactive mode.

Uninstall

  1. Remove the source /usr/local/bin/fuzzycd line from your startup script(s) (~/.bashrc and/or ~/.zshrc).
  2. Delete /usr/local/bin/fuzzycd.
  3. Optionally, delete the history file (~/.fuzzycd-history).
  4. Retsrat your session.

Contributing / Support

If you experience any issue, have a question or a suggestion, or if you wish to contribute, feel free to open an issue.


fuzzycd's People

Contributors

dannyben avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mycargus

fuzzycd's Issues

Allow customizing the fzf command

This can be done in one of two ways (or both):

  1. Allow complete customization using FUZZYCD_FZF_COMMAND environment variable.
  2. Allow selecting "presets" - for example, with interactivity or without.

Add ability to delete directory from the history

Would be nice to be able to do:

# delete current directory from history
$ cd -d

# delete other directory from history
$ cd -d /some/dir

Then, in addition, we can probably bind the del key to run this and reload, when using the interactive menu.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.