GithubHelp home page GithubHelp logo

bom-d-van / dir_tagger Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 164 KB

A gem saving some frequent used paths and keeping them at hand, both in a very ease and comportable way. The concept is to give your directory a tag, and then store it in '~/.tag_dir_profile'. After that, you can retrieve the path of the directory by a shell command with the tag as parameter.

Home Page: https://github.com/bom-d-van/dir_tagger

Ruby 100.00%

dir_tagger's Introduction

DirTagger

A gem saving some frequently-used paths and keeping them at hand, both in a very ease and comportable way. The concept is to give your directory a tag, and then store it in '~/.tag_dir_profile'. After that, you can retrieve the path to the directory by a shell command by passing the tag as parameter. https://github.com/bom-d-van/dir_tagger

Examples

$ dir_tagger -h
# Usage: tagdir tag[,directory] [options]
# 
# SPECIFIC OPTIONS:
#     -a, --add tag[,directory]        Tag a directory, the defaualt directory is the current directory
#     -u, --under tag[,tag2, ..]       Operate tag within parent tags
#     -r, --remove tag,[tag2, ..]      Remove one or more tags
#     -l, --list                       List all the saved paths
#     -t, --tags [pattern1, ..]
#     -d, --dir [pattern1, ..]
#     -v, --version                    List current TagDir Version
#     -h, --help                       Display help message

# Tag a directory
# Assume you are in such a path: ~/path/to/home
$ dir_tagger -a home
# Add Success

# Retrieve directory by the tag
$ dir_tagger home
# ~/path/to/home

# Ruby style regexp support.
$ dir_tagger ho
# ~/path/to/home

# Nested Tagging
$ echo pwd
# ~/path/to/home/code
$ dir_tagger -a code -u home
# Add Success
$ dir_tagger ho co
# ~/path/to/home/code

# Display all the saved tags and directories
$ dir_tagger
# All the saved paths:
#       home    ~/path/to/home
#           home    ~/path/to/home/code

Using dir_tagger in shell

# use rcd with cd command
$ cd $(rcd home)

# some powerful shell snippets with dir_tagger
function xto {
    xto_path=$(dir_tagger $*)
    if [[ "$xto_path" != "" ]]; then
        cd "$xto_path"
    else
        echo -e '\033[31mPath Not Existed!\033[0m'
    fi
}

function xmate {
    proj=$(dir_tagger $1)
    proj_name=$(dir_tagger -k $1)
    tmproj=$proj/$proj_name.tmproj
    if [[ -f $tmproj ]]; then
        open "$tmproj"
    elif [[ "$proj" != "" ]]; then
        mate "$proj"
    else
        echo -e '\033[31mPath Not Existed!\033[0m'
    fi
}

function xproj {
    xmate $*
    xto $*
}

$ pwd
# somewhere/else
$ xto ho
# path/to/home

And that's all, hope you enjoy my first ruby gem. :-)

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.