Skip to content

Instantly share code, notes, and snippets.

@drrobotnik
Last active August 29, 2015 14:26
Show Gist options
  • Save drrobotnik/dd6ff12772b7cfcf37ed to your computer and use it in GitHub Desktop.
Save drrobotnik/dd6ff12772b7cfcf37ed to your computer and use it in GitHub Desktop.
traverse
cdd() {
cd `php ~/bin/traverse $1`
}
#!/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