Last active
December 15, 2015 23:00
-
-
Save longarm/5337397 to your computer and use it in GitHub Desktop.
In Perforce, user will have a request to jump between center and local client by soft link .s
for example local client directory: /a/b/c/d/e/f ; center directory /a/b/c/.s/d/e/f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
currentPath=os.getcwd() | |
tail='' | |
while currentPath != '/': | |
aa=os.path.split(currentPath) | |
tail=os.path.join(aa[1], tail) | |
if os.path.lexists(os.path.join(aa[0],'.s')): | |
os.chdir(os.path.join(aa[0], '.s', tail)) | |
break | |
currentPath=aa[0] | |
print os.getcwd() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env tcsh | |
# description: change dir based on .s | |
# with any arguments to go back | |
# TODO there is some problems with heredoc | |
set pd= | |
set cc= | |
set origin=$PWD | |
while ( 0 == 0 ) | |
if ( -d .s ) then | |
set pd=.s/$pd | |
cd $pd | |
break | |
endif | |
set cc=$PWD | |
set cc=`echo $cc | sed -e 's/.*\/\(.*\)/\1/g'` | |
if ( $cc == "") then | |
cd $origin | |
break | |
endif | |
if ( $cc != ".s" ) then | |
set pd=$cc/$pd | |
else | |
cd .. | |
cd ./$pd | |
break | |
endif | |
cd .. | |
end | |
#pwd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wanna go back