GithubHelp home page GithubHelp logo

nastevens / dnav Goto Github PK

View Code? Open in Web Editor NEW

This project forked from posborne/dnav

0.0 2.0 0.0 124 KB

Directory Navigator helps you quickly navigate to directories by name

License: MIT License

Python 79.08% Shell 20.92%

dnav's Introduction

dnav: Directory Navigator

The Problem

When working on various projects on a linux system, there are several directories that one is likely to going to be jumping between at any given time. Changing between these directories can be a pain and existing tools like pushd and popd provide support for going back to directories that were previously pushed onto a stack.

Wouldn't it be nice if there were a command-line tool that would...

  1. Allow me to jump to a directory quickly based on an alias I define?
  2. Remember these aliases across shell sessions?
  3. Provide familiar commands for managing directory aliases?

You're in luck. This is what dnav is designed to provide. Instead of managing your directories on a stack, now you have a hash table and you can get, put, go, rm, and clear aliases in this table with simple commands.

Install It

Install dnav by cloning the git repo to your home directory as follows

$ git clone https://github.com/posborne/dnav ~/.dnav

Enable shell integration (which allows dnav to modify your current working directory) by adding the following to your .bashrc, .zshrc, or other shell configuration file.

source ~/.dnav/dnav.sh

That's it. Don't forget to restart your shell or re-source your shell init for the update to take effect. To test, you should be able to run the following:

dnav --help

Basic Usage/Examples

There aren't too many subcommands for dnav and they are all pretty intuitive. Here's the basic ones that you are likely to use most frequently.

Add and Navigate

$ cd ~/Projects/wizzbang
$ dnav add wb  # nice and short
$ cd ../other-project
$ dnav add op
$ dnav cd wb
$ pwd
/home/user/Projects/wizzbang
$ dnav cd op
$ pwd
/home/user/Projects/other-project

List Aliases

$ dnav list
op -> /home/user/Projects/other-project
wb -> /home/user/Projects/wizzbang

Removing an Alias

$ dnav rm op
$ dnav list
wb -> /home/user/Projects/wizzbang

Cleaning up Bad Links

$ mv ~/Projects/other-project ~/Projects/super-wizzbang
$ dnav list
op -> /home/user/Projects/other-project (broken)
wb -> /home/user/Projects/wizzbang
$ dnav prune
Removing bad alias op -> /home/user/Projects/other-project
$ dnav list
wb -> /home/user/Projects/wizzbang

Starting Fresh

$ dnav clear

Using dnav with other Unix Tools

# 'dnav show <alias>' just outputs the path 'op' points to
$ find `dnav show op` -name '*.txt'
...

How Does It Work

dnav has two main pieces:

  1. A shell script which is sourced in your shell environment that provides the dnav command. This is necessary for dnav to change your current working directory.
  2. A python scipt that implements the core functionality of dnav which is called out to by the shell function.

The only state used by dnav is a set of symlinks that are stored in ~/.dnav/symlinks. The various dnav commands are just operations on the symlinks in this directory. For instance, the command dnav prune just goes through this directory and removes any links which point to targets that are no longer present.

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.