aboutsummaryrefslogtreecommitdiff
path: root/sh/shrc.d/gd.sh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-01-02 15:50:52 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-01-02 15:50:52 +1300
commitca20e3e759d168a9f4dacdb05dad2a2b295f458b (patch)
tree687b7c6c983933e0e7fa04c8a631dbc7a0386e58 /sh/shrc.d/gd.sh
parentRemove an unnecessary trailing slash from ad() (diff)
downloaddotfiles-ca20e3e759d168a9f4dacdb05dad2a2b295f458b.tar.gz
dotfiles-ca20e3e759d168a9f4dacdb05dad2a2b295f458b.zip
Add marked-dir tools
Diffstat (limited to 'sh/shrc.d/gd.sh')
-rw-r--r--sh/shrc.d/gd.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/sh/shrc.d/gd.sh b/sh/shrc.d/gd.sh
new file mode 100644
index 00000000..754bd8ff
--- /dev/null
+++ b/sh/shrc.d/gd.sh
@@ -0,0 +1,18 @@
+# Go to marked directory
+gd() {
+
+ # Refuse to deal with unwanted arguments
+ if [ "$#" -gt 0 ] ; then
+ printf >&2 'gd(): Unspecified argument\n'
+ return 2
+ fi
+
+ # Complain if mark not actually set yet
+ if ! [ -n "$PMD" ] ; then
+ printf >&2 'gd(): Mark not set\n'
+ return 2
+ fi
+
+ # Go to the marked directory
+ cd -- "$PMD"
+}