Created
May 24, 2015 12:48
-
-
Save jakowicz/3e03e15f698f9e9251cd to your computer and use it in GitHub Desktop.
cd change-up
This file contains 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
#!/bin/bash | |
function changeDir() { | |
foo=$(getRandomDir '/*/') | |
while [ 1 == 1 ]; do | |
if [ "$foo" != "" ]; then | |
builtin cd $foo 2> /dev/null | |
foo=$(getRandomDir '*/') | |
else | |
break; | |
fi | |
done | |
echo "I am not some slave, I'll cd to '`pwd`' instead" | |
} | |
function getRandomDir() { | |
echo `/usr/bin/ls -d $1 -1 2> /dev/null | shuf | head -n 1` 2> /dev/null | |
} | |
alias cd="changeDir" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment