aboutsummaryrefslogtreecommitdiff
path: root/sh/shrc.d/md.sh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-01-02 16:00:15 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-01-02 16:00:15 +1300
commitcd7b34f27453b222c9b9fd26c14d56f7c88a3643 (patch)
treeb4cd8f8601e6eb70b0a4d73e2d9b91714b4ff40f /sh/shrc.d/md.sh
parentAdd completion for md() (diff)
downloaddotfiles-cd7b34f27453b222c9b9fd26c14d56f7c88a3643.tar.gz
dotfiles-cd7b34f27453b222c9b9fd26c14d56f7c88a3643.zip
Handle simple relative dirs in md()
And add an issue about handling complex ones
Diffstat (limited to 'sh/shrc.d/md.sh')
-rw-r--r--sh/shrc.d/md.sh9
1 files changed, 9 insertions, 0 deletions
diff --git a/sh/shrc.d/md.sh b/sh/shrc.d/md.sh
index cf44abb3..1f8a8aaf 100644
--- a/sh/shrc.d/md.sh
+++ b/sh/shrc.d/md.sh
@@ -10,6 +10,15 @@ md() {
# If first arg unset or empty, assume the user means the current dir
[ -n "$1" ] || set -- "$PWD"
+ # If specified path is . or .., quietly expand it
+ case $1 in
+ .) set -- "${PWD%/}" ;;
+ ..)
+ set -- "${PWD%/}"
+ set -- "${1%/*}"
+ ;;
+ esac
+
# If specified path not a directory, refuse to mark it
if ! [ -d "$1" ] ; then
printf >&2 'md(): Not a directory\n'