aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2016-07-21 22:40:31 -0400
committerTeddy Wing2016-07-21 22:40:31 -0400
commit65a0fbd001f5cec3f90441b2a25da3fe32afc2ef (patch)
tree908e76abe7791ad1855f96f90b14779bc8a34441
parent4992f6d91962692a55c51498af55093c4905b98f (diff)
downloadqcd-65a0fbd001f5cec3f90441b2a25da3fe32afc2ef.tar.bz2
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.
-rwxr-xr-xqcd10
1 files changed, 10 insertions, 0 deletions
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
}