Last active
December 15, 2015 22:59
-
-
Save delta4d/5336680 to your computer and use it in GitHub Desktop.
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= | |
while ( 0 == 0 ) | |
if ( -d .s ) break | |
set cc=`pwd` | |
set cc=`echo $cc | sed -e 's/.*\/\(.*\)/\1/g'` | |
if ( $# == 0 || $cc != ".s" ) set pd=$cc/$pd | |
#echo $pd | |
cd .. | |
end | |
if ( $# == 0 ) set pd=.s/$pd | |
#echo $pd | |
cd $pd | |
pwd |
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 sh | |
pd= | |
while true; do | |
[[ -d .s ]] && break | |
cc=`pwd` | |
pd=${cc##*/}/$pd | |
# echo $pd | |
cd .. | |
done | |
pd=.s/$pd | |
#echo $pd | |
cd $pd | |
pwd |
Author
delta4d
commented
Apr 9, 2013
#!/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
# echo $pd
cd ..
end
pwd
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment