Quick Switch directory command go

Source: Internet
Author: User

There are many project directories in normal times, which need to be switched frequently, with low efficiency. Previously, I always Ctrl + R or CD-in shell, but it was hard to make me a lazy person if I had more directories, if you repeat something three times, you can't bear it. Then, you can use python to create a go command, so that you can easily switch directories to the code first.

#. Add go () {CD $ (Python/users/auxten/scripts/thepath. py "$1")} to bashrc ")}

/Users/auxten/scripts/thepath. py:

#! /Usr/bin/ENV Python #-*-coding: utf8-*-import sysimport ospath_dic = {"flow ": "/users/auxten/codes/Android/VPN/flow", "BYOD": "/users/auxten/codes/Android/BYOD/git/BYOD", "vine ": "/users/auxten/codes/Baidu/OPS-src/OPS-vine", "gko": "/users/auxten/codes/gko_pool", "CDN ": "/users/auxten/codes/Baidu/OPS-src/dlplatform/log_analytics/web/web_env/", "proxy ": "/users/auxten/Dropbox/plug-in/spiderproxy/", "VPN ":"/ Users/auxten/codes/Android/VPN/flow ",} search_path = ["/users/auxten/codes/Android/BYOD/trunk /", "/users/auxten/codes/Baidu/OPS-src/", "/users/auxten/codes/",] Path = "~ "Try: Path = path_dic [sys. argv [1] Does T keyerror, indexerror: For dir in search_path: tmp_path = OS. path. join (Dir, sys. argv [1]) If OS. path. isdir (tmp_path): Path = tmp_path break print path

If you specify

"flow":"/Users/auxten/Codes/Android/VPN/flow",
Go flow # is equivalent to CD/users/auxten/codes/Android/VPN/flow

If it is not specified in path_dic, the flow folder will be searched in order in search_path, and then the CD will go in.

 

Quick Switch directory command go

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.