Last active
August 29, 2015 14:26
-
-
Save drrobotnik/dd6ff12772b7cfcf37ed to your computer and use it in GitHub Desktop.
traverse
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
cdd() { | |
cd `php ~/bin/traverse $1` | |
} |
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/php | |
<?php | |
$results = exec('echo $(find . -type d -name ' . $argv[1] . ')'); | |
$results_array = explode(' ', $results); | |
$new = array(); | |
foreach ($results_array as $key => $value) { | |
$temp = explode('/', $value); | |
$new[count($temp)][] = $temp; | |
} | |
ksort($new); | |
foreach ($new as $entry) { | |
$new = array_shift($entry[0]); | |
$path = implode('/', $entry[0]); | |
echo './'.$path; | |
exit; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment