aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2016-12-03 19:34:31 -0500
committerTeddy Wing2016-12-03 19:34:31 -0500
commit34fa3b6057ac0d31da4fa3f03d5c1b3746a2339e (patch)
tree8a5fa8a70902c1ac9ed382ea372bc5a8f1bc1534
parentd4a01f9987f6ce35f7604a247f1d6ff7c2c96eba (diff)
downloadqcd-34fa3b6057ac0d31da4fa3f03d5c1b3746a2339e.tar.bz2
qcd: Add option to list shortcuts
Sometimes it's helpful to list the shortcuts you've added to help you remember what they were. I had been doing `cat ~/.config/qcd/database` for this, but it's nice to have it as part of the `qcd` command and also to not have to type all that.
-rwxr-xr-xqcd10
1 files changed, 9 insertions, 1 deletions
diff --git a/qcd b/qcd
index 3d966bb..4cb18fa 100755
--- a/qcd
+++ b/qcd
@@ -14,7 +14,7 @@ function __qcd_print_usage () {
cat 1>&2 <<__EOF__
Usage:
qcd SHORTCUT
- qcd -acrh SHORTCUT [PATH]
+ qcd -acrlh SHORTCUT [PATH]
The first call changes to the directory specified by SHORTCUT.
The second allows manipulation of the shortcut database.
@@ -22,6 +22,7 @@ Usage:
-a Add a new shortcut pointing to PATH
-c Change an existing shortcut to PATH
-r Remove SHORTCUT
+ -l List shortcuts
-h Display this help
__EOF__
}
@@ -71,6 +72,10 @@ function __qcd_remove_shortcut () {
fi
}
+function __qcd_list_shortcuts () {
+ column -t -s ' ' $QCD_DATABASE_FILE | sort
+}
+
function __qcd_change_directory () {
local shortcut=$1
@@ -106,6 +111,9 @@ function qcd () {
-r)
__qcd_remove_shortcut $shortcut
;;
+ -l)
+ __qcd_list_shortcuts
+ ;;
-h|--help)
__qcd_print_usage
;;