Turn from: http://www.ccvita.com/520.html, slightly modified.
Daily at the command line, a large part of the work is over and over the input CD ~/some/very/deep/often-used/directory this to switch directories, now with a simple configuration can achieve the following effect:
First enter my daily work directory, mark a bookmark Mark Sanguo
cd/users/kimi/work/123guo/Sanguomark Sanguo
I will enter this directory in the future only G Sanguo can be
G Sanguo
Browse all tags by entering the GS command
/library/webserver/documents,/users/kimi/work/123guo/,/-
The implementation principle is as follows (own implementation)
sudo vim/etc/profile
Edit the/etc/profile file and force save after adding the following at the end wq!
# Markexport Markpath= $HOME/. Marksexport Markdefault=sanguo# Set your default bookmark, you can directly enter G jump function g {local m=$1 if["$m"=""]; Then m=$MARKDEFAULT; Fi cd-P"$MARKPATH/$m" 2>/dev/NULL|| Echo"No such mark: $m"}function Mark {mkdir-P"$MARKPATH"Local M=$1 if["$m"=""]; Then m=$MARKDEFAULT; Fi rm-F"$MARKPATH/$m"LN-S"$ (PWD)" "$MARKPATH/$m"}function Unmark {local M=$1 if["$m"=""]; Then m=$MARKDEFAULT; Fi rm-I."$MARKPATH/$m"}function GS {ls-L"$MARKPATH"| grep ^l | Cut-d' '-F --} _completemarks () {Local CURW=${comp_words[comp_cword]} local wordlist=$ (ls-l"$MARKPATH"| grep ^l | Cut-d' '-F -) compreply= ($ (compgen-w'${wordlist[@]}'--"$CURW")) return 0} Complete-F _completemarks G unmark
MAC quickly switches directories on the command line mark