From f4f96bd6be1bce5f4a5c3d128e1ce3e2f480595f Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 21 Jul 2016 22:06:26 -0400 Subject: 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. --- qcd | 7 +++++++ 1 file changed, 7 insertions(+) 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) ;; -- cgit v1.2.3