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