From 30f42331e813c205ed8f011e11258e21dd24f4d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferit=20Yi=C4=9Fit=20BALABAN?= Date: Thu, 25 May 2023 07:39:00 +0300 Subject: [PATCH] johnny.decimal special --- cdd.bash | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 cdd.bash diff --git a/cdd.bash b/cdd.bash new file mode 100755 index 0000000..7627138 --- /dev/null +++ b/cdd.bash @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# +# Ferit Yiğit BALABAN, +# +# cd on steroids for Johnny.Decimal directories + +# Define the cdd function +cdd() { + local input="$1" + local folder="$(basename "$PWD")" + + if [[ "$input" =~ ^[0-9]{3}\.[0-9]{2}$ ]]; then + cd "$HOME/shoka/*/*/$input *" + elif [[ "$input" =~ ^[0-9]{3}$ ]]; then + cd "$HOME/shoka/*/$input *" + elif [[ "$input" =~ ^[0-9]{2}$ && "$folder" =~ ^[0-9]{3} ]]; then + cd "$HOME/shoka/*/*/${folder:0:3}.$input *" + else + echo "Invalid input: $input" + fi +} + +# Use the cdd function with the input argument +cdd "$1"