aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2016-07-21 22:06:26 -0400
committerTeddy Wing2016-07-21 22:06:26 -0400
commitf4f96bd6be1bce5f4a5c3d128e1ce3e2f480595f (patch)
treebcf46ae10148ced38b32cdaafebcfa005c0174f2
parente09b306850f080d3deeb8660243baa7ec0282f37 (diff)
downloadqcd-f4f96bd6be1bce5f4a5c3d128e1ce3e2f480595f.tar.bz2
qcd: Add "change" command
Option to change the path referenced by a given shortcut. Uses `sed` to make the replacement and write out the updated database file. Using the `-E` flag on `sed` so that the `+` regex operator works. The `-E` flag works on OS X, but on Linux with GNU sed, it would be the `-r` flag instead.
-rwxr-xr-xqcd7
1 files changed, 7 insertions, 0 deletions
diff --git a/qcd b/qcd
index b069963..efb0f59 100755
--- a/qcd
+++ b/qcd
@@ -56,6 +56,13 @@ function qcd () {
fi
;;
-c)
+ local shortcut=$2
+ local path=$3
+
+ if shortcut_exists $shortcut; then
+ path=$(absolute_path $path)
+ sed -i.bak -E "s/^${shortcut} .+$/${shortcut} ${path//\//\/}/" $QCD_DATABASE_FILE
+ fi
;;
-r)
;;