From 65a0fbd001f5cec3f90441b2a25da3fe32afc2ef Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 21 Jul 2016 22:40:31 -0400 Subject: qcd: When a shortcut is passed, `cd` into the corresponding directory Look up the given shortcut in the database and change to the directory it points to. --- qcd | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/qcd b/qcd index 698cf9f..58740ec 100755 --- a/qcd +++ b/qcd @@ -63,6 +63,15 @@ function remove_shortcut () { fi } +function change_directory () { + local shortcut=$1 + + cd $(awk -v shortcut="$shortcut" '{ + if ($1 == shortcut) + { print $2 } + }' $QCD_DATABASE_FILE) +} + function qcd () { if [[ $# < 1 ]]; then print_usage @@ -89,6 +98,7 @@ function qcd () { print_usage ;; *) + change_directory $command ;; esac } -- cgit v1.2.3