Skip to content

htc502/map

Repository files navigation

📍 map

This is a commandline tool like alias, but applied on file path. It saves your time when the file paths are deep by using a set of bookmarks.

How to install

To compile it from source under linux and Mac, type:
cd source_dir ##source_dir: where the source code was stored
make
(Optional) if you want to add it to your system PATH:
  1. mv or ln -s the map binary and the map_go.sh script to a location in your path.
  2. source map_go.sh in your .bashrc or .bash_profile

A file called .pathmark.db will be generated in $HOME dir on the first run of this widget

Compile under windows

The source code was tested with codeblock 13.12 using mingw-gcc(gcc ver4.7.1 32bit), to use it under win, enviroment variable named HOME should be avilable(right click 💻 ➡️ properties ➡️ advanced ➡️ enviroment variable).

Examples

Bookmark a directory

cd to target directory and type:

map bookmark .

This will add a new bookmark to .pathmark.db. Avoid using number as a bookmark.

List all bookmarks:

To browse those directories bookmarked, type:

map

if you want check a specific bookmark, type:

map bookmark
Go to a bookmarked location

Try to cd to a place marked with "wd":

g wd

or just use the index number of "wd" showed when you type map:

g indexofwd

g is a function defined in map_go.sh which help type the following code ( "" quotes in case if the path has whitespaces):

cd "`map wd`"

By default, map only record the last 20 bookmarks you add. The oldest record will be discard when more records come in. Modify MAX_NPATH variable in pathmark_db.c before compilation to change the limit. Be sure that this number is <= 99 because of current argument parsing strategy (If try to deal with more than 100 directories, then probably you need to hack the argument parsing strategy code).

To remove a specified bookmark
  map -index

Here, the index starts from 0 to n-1, i.e. the first record will be removed by 👽 :

  map -0

Enjoy!

image