GithubHelp home page GithubHelp logo

demille / bookmark Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 0.0 349 KB

Directory bookmark tool: use bm <bookmark> instead of cd /really/long/path/

License: MIT License

JavaScript 39.56% Shell 36.09% Batchfile 24.36%

bookmark's Introduction

bookmark

A cross-platform command line bookmarking tool

With bookmark you can type bm myProject to move to a bookmarked directory instead of cd /really/long/path/to/myProject.

What?

I ain't tryin' to waste my time typing out long paths all day. If you have used python's virtualenvwrapper before, you might miss how the workon command can switch directories for you. Bookmark aims to be like that, but for any directory.

Much better right?

Install

Bookmark requires Node.js

$ npm install -g bookmark

then, for bash / zsh:

$ . bm --add-alias

Bookmark relies on .sh/.bat scripts to do its magic. Bookmark feeds those scripts the path you want to cd to. For a script's cd command to actually change the directory in your current shell you need to 'source' that script.

Typing $ source bm <bookmark> every time is lame. You can avoid typing source each time by manually adding an alias (bm="source bm") to your .bash_aliases or .bashrc, or you can let bookmark try to add it for you with $ . bm --add-alias.

How to use

Usage: bm [options] [command]

Commands:

  add <bookmark_name> [bookmark_path]
  update <bookmark_name> [bookmark_path]
  remove <bookmark_name>
  list [bookmark_name]
  <bookmark_name>

Options:

  -h, --help  output usage information
  -v  output the version number

Commands can also be truncated for less typing:

  • add / a
  • update / up / u
  • remove / rm / r
  • list / ls / l

Bookmarks are saved in bookmark.db in your home directory.

Examples

# Add a bookmark called myProject at current location:
$ bm add myProject

  Bookmark added:
  myProject C:\User\Person\Projects\myProjectStuff

# Add a bookmark called myProject at given path:
$ bm add myProject \User\Person\Projects\myProjectStuff

  Bookmark added:
  myProject C:\User\Person\Projects\myProjectStuff

# cd to your bookmark's directory
$ bm myProject

Is there a better way to do this?

Probably, but I don't know what it is. I've seen some complex shell scripts floating around the web, but they didn't seem to do exactly what I wanted and I couldn't find any solutions for Windows machines.

It might have been better to exclude Node and only use .sh/.bat scripts, but my .sh/.bat-scripting-fu isn't up to that challenge.

Changelog

  • 0.2.0 - Support for zsh, fixes for npm prefix paths with spaces
  • 0.2.1 - Fixed windows/cygwin accidental escape chars in path
  • 0.2.2 - Updated commander.js dep
  • 0.2.3 - Fixed find command issue

License

The MIT License (MIT)

Copyright (c) 2014 Sterling DeMille

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

bookmark's People

Contributors

demille avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bookmark's Issues

Feature Request: prompt to add if you forget to type "add"

First of all, I LOVE bm. I've only had it for 2 hours and it's already saved me so much time. Thank you x1000000.

But I am noticing that when adding bookmarks, I'm constantly forgetting to type "add" (because I'm stupid) and keep typing "bm {name}", and bm replies "This bookmark does not exist yet." Do you think it would be possible for bm to prompt there something like "Would you like to create one (y/n)?" That would be awesome. I'd do it myself, but I don't know that much about shell scripts and I'm figuring this isn't that hard of a change.

Thanks!

Can't run bm anymore

After adding the alias in the ~/.bashrc I got the next error:

~ ❯ bm list
listBookmark:1: no such file or directory: node /Users/lib/node_modules/bookmark/index.js

~ ❯ bm -h
getHelp:1: no such file or directory: node /Users/lib/node_modules/bookmark/index.js

~ ❯ bm add something
addBookmark:7: no such file or directory: node /Users/lib/node_modules/bookmark/index.js

OS: OS X 10.11.1
Node.js: v5.0.0
npm: v3.3.9
Shell: zsh 5.0.8 (x86_64-apple-darwin15.0)

Error in Cygwin

Used to use normal Windows command line and it worked great, but then when switching to Cygwin, I run into this problem:

-bash: [: C:\users\tobias087\documents\Sam's: unary operator expected

No idea what that means. Good luck.

(Should mention though that that is a truncation of the full directory, which should have been "C:\users\tobias087\documents\Sam's Stuff/Programming" Maybe it didn't like the space?)

Feature idea: interactive mode

I was thinking about how to make bookmark even more comfortable. Then I had the idea of an kind of interactive mode that pops up when you just enter bm. I'm not sure yet how it should behave though.

One idea is to select an entry with arrow keys and go to that folder by pressing enter.

The other idea is a more vim-ish approach where you select a bookmark by pressing 1 - 9.

Both could be paired with a filter (using fuzzy search) to access every entry in a big list very quickly.

What do you think?

Error when naming a bookmark "shift"

I've tried to create a bookmark named "shift". Since then some commands stopped working.

The bookmark was created successfully. I can see that by typing bm ls. (this still works)

But bm --help creates an error:

find: '/n/Abteilungsleitung': Permission denied

When I try to remove that bookmark by typing bm rm shift I get a bit more detailed error:

find: '/n/Abteilungsleitung': Permission denied
module.js:472
    throw err;
    ^

Error: Cannot find module 'C:\Users\linnert\AppData\Roaming\npm\node_modules\bookmark\cli\cli-shift'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:422:7)
    at startup (bootstrap_node.js:143:9)
    at bootstrap_node.js:537:3

I have no idea where this Abteilungsleitung is coming from. It's a German word, but I can't find a folder or file that's named like this nor can I fand this word in your source code...

UPDATE:

Okay, I found a folder with the name "Abteilungsleitung". But it's behind a symlink that's pointing to a network drive. Why does bookmark stumble over that directory? No action I did was related to that symlink.

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.