Code Monkey home page Code Monkey logo

bash-bookmarks's Introduction

bash-bookmarks

A simple utility that allows you to easily save your current working diretory by assigning it a named bookmark. You can then easily cd mybookmark, or use your bookmark as a Bash variable.

Example

mtorok (Desktop)$ cd test_1/
mtorok (test_1)$ bookmark tests
Created bookmark tests to /Users/mtorok/Desktop/test_1
mtorok (Desktop)$ cd tests
/Users/mtorok/Desktop/test_1
mtorok (test_1)$ cd ..
mtorok (Desktop)$ showbookmarks 
tests=/Users/mtorok/Desktop/test_1
mtorok (Desktop)$ rm -rf $tests
mtorok (Desktop)$ rmbookmark tests
mtorok (Desktop)$ 

Installation

Save bash-bookmarks.sh somewhere on your system and add the following line to your ~/.bash_profile:

[[ -s ~/bash-bookmarks.sh ]] && . ~/bash-bookmarks.sh

Change the path to bash-bookmarks.sh to reflect its location on your system. Close and re-open Bash and the bookmark commands should be available.

Usage

  • bookmark name: Create a new bookmark named name, pointing to the current directory.
  • showbookmarks: List all bookmarks.
  • rmbookmark name: Delete the bookmark named name.

Configuration

By default, bookmarks are stored in ~/.bookmarks. You can change this by setting the $BOOKMARK_FILE shell variable before bash-bookmarks.sh is first sourced, e.g. by adding the line BOOKMARK_FILE=~/Documents/bash-bookmarks to ~/.bash_profile before the [[ -s ~/bash-bookmarks.sh ]] && . ~/bash-bookmarks.sh line.

Note that bookmarks aren't automatically transfered to any new file you specify, so if you want to keep existing bookmarks, you'll need to copy the old bookmark file to the new file.

Note also that if you change this value, is is highly reccomended to close and re-open your prompt. Otherwise, bookmarks from the old file will still be visible, yet all add/list/delete operations will happen over the new bookmark file.

Caveats

All bookmark names must obey Bash variable naming rules: they must be one word, start with a letter or underscore, and contain only letters, numbers and underscores.

You can only bookmark your current working directory. If there is demand, support may be added for bookmarking arbitrary directories.

Credit

There are a number of similar utilities floating around the net. This one was inspired by a page I've since lost, and adapated heavily for my use. If you recognize the base script, drop me a line so that I may credit it properly.

bash-bookmarks's People

Contributors

int3h avatar

Watchers

 avatar  avatar

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.