MAC quickly switches directories on the command line mark

Source: Internet
Author: User
Tags switches

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.