This is a maintained fork of mollifier/cd-bookmark that adds the following features:
Migrating from bashmarks? Then the following aliases will make you feel at home:
alias g='cd-bookmark -c'
alias s='cd-bookmark -a'
alias l='cd-bookmark -l'
alias e='cd-bookmark -e'
alias p='cd-bookmark -p'
alias d='cd-bookmark -d'
$ git rebase -ir upstream/master
zsh and bash plugin to bookmark directories to cd.
Inspired by mokemokechicken post and shell script in the post.
This plugin is forked from the script. The original script is licensed under the MIT License.
Put cd-bookmark and _cd-bookmark files somewhere in your $fpath and add the following line to your .zshrc:
autoload -Uz cd-bookmark
# download all files
% cd /path/to/dir
% git clone https://github.com/erikw/cd-bookmark.git
And add the following lines to your .zshrc:
fpath=(/path/to/dir/cd-bookmark(N-/) $fpath)
autoload -Uz cd-bookmark
If you use Antigen, add the following line to your .zshrc:
antigen bundle erikw/cd-bookmark
You can set alias to this function. e.g.
alias cdb='cd-bookmark'
For bash users, put this in your shell initialization file (typically $HOME/.bashrc
):
source path/to/dir/cd-bookmark/cd-bookmark
# 1st form
% cd-bookmark -a [BOOKMARK_ID]
# or
# 2nd form
% cd-bookmark [-c] BOOKMARK_ID
# or
# 3rd form
% cd-bookmark [-l]
In the 1st form, add current directory to bookmark with BOOKMARK_ID. BOOKMARK_ID is used as a key in bookmark.
In the 2nd form, find directory by BOOKMARK_ID and change directory to it. In this form, you can add relative path from bookmark real path at the end of BOOKMARK_ID (see example below).
In the 3rd form, list current bookmark.
-a
[BOOKMARK_ID] add current directory to bookmark
with no BOOKMARK_ID, automatically use free ID number as BOOKMARK_ID-c
BOOKMARK_ID change directory which is identified by BOOKMARK_ID-d
BOOKMARK_ID delete directory which is identified by BOOKMARK_ID-l
list bookmark-e
edit bookmark file-p
BOOKMARK_ID display bookmark real path for BOOKMARK_ID-h
display this help and exit
The location of the bookmarks list file depends on the envionment's configuration. The file is searched in the following order:
$CD_BOOKMARK_FILE
- if it is set. This has highest precedence. Thus you can set this to override to custom location.$XDG_CONFIG_HOME/cd-bookmarks/bookmarks
- if the directorycd-bookmarks/
exist. Note that$XDG_CONFIG_HOME
defaults to$HOME/.config
$HOME/.cdbookmark
- fall back to old default $HOME/.cdbookmark
# Current directory is '/home/mollifier/work'.
% pwd
/home/mollifier/work
# Add current directory to bookmark. It's bookmark ID is 'work'.
% cd-bookmark -a work
# cd somewhere.
% cd
# Back to 'work' directory.
% cd-bookmark work
% pwd
/home/mollifier/work
# Add another directory to bookmark.
% cd /home/mollifier/tmp
% cd-bookmark -a tmp
# To show current bookmark, run cd-bookmark without any options or with -l option.
% cd-bookmark
tmp|/home/mollifier/tmp
work|/home/mollifier/work
# You can add relative path from bookmark real path at the end of BOOKMARK_ID.
% cd-bookmark work/project/zsh
% pwd
/home/mollifier/work/project/zsh
# To edit bookmark, run cd-bookmark with -e option.
% cd-bookmark -e
# Open bookmark file with $EDITOR (vim, emacs, etc.), so you can edit bookmark.
# To delete a bookmark, run cd-bookmark with -d option.
% cd-bookmark -d work