diff options
| author | Teddy Wing | 2016-07-21 22:40:31 -0400 |
|---|---|---|
| committer | Teddy Wing | 2016-07-21 22:40:31 -0400 |
| commit | 65a0fbd001f5cec3f90441b2a25da3fe32afc2ef (patch) | |
| tree | 908e76abe7791ad1855f96f90b14779bc8a34441 | |
| parent | 4992f6d91962692a55c51498af55093c4905b98f (diff) | |
| download | qcd-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-x | qcd | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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 } |
