Created
June 10, 2009 14:39
-
-
Save rupa/127250 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
| function rat { | |
| # change part of pwd path, and cd to it | |
| # example: | |
| # /usr/lib/foo$ rat li src | |
| # /usr/src/foo$ | |
| local cd=$(echo $PWD | awk -v q="$*" -F\/ ' | |
| BEGIN { l = split(q,a," ") } | |
| { | |
| for( i=1;i<=NF;i++ ) { | |
| for( j=1;j<=l;j=j+2 ) { | |
| if( !a[j] || $i !~ a[j] ) continue | |
| $i = a[j+1] | |
| delete a[j] | |
| } | |
| } | |
| for( i=1;i<=NF;i++ ) printf $i "/" | |
| } | |
| ') | |
| [ -d "$cd" ] && cd $cd | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment