aboutsummaryrefslogtreecommitdiff
path: root/bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2015-08-05 14:42:56 +1200
committerTom Ryder <tom@sanctum.geek.nz>2015-08-05 14:42:56 +1200
commit19150e2a5f4f5c1b083a4988ce801141815bf1a3 (patch)
treea1cd7d13417d8d31bfbdb26bd241bf4a1ea87d52 /bash
parentImprove comments (diff)
downloaddotfiles-19150e2a5f4f5c1b083a4988ce801141815bf1a3.tar.gz
dotfiles-19150e2a5f4f5c1b083a4988ce801141815bf1a3.zip
Pass options to cd from ud
Diffstat (limited to 'bash')
-rw-r--r--bash/bashrc.d/ud.bash21
1 files changed, 20 insertions, 1 deletions
diff --git a/bash/bashrc.d/ud.bash b/bash/bashrc.d/ud.bash
index 2428ba54..5bcfc2ed 100644
--- a/bash/bashrc.d/ud.bash
+++ b/bash/bashrc.d/ud.bash
@@ -2,6 +2,25 @@
# like cd .., cd ../.., etc
ud() {
+ # For completeness' sake, we'll pass any options to cd
+ local arg
+ local -a opts
+ for arg ; do
+ case $arg in
+ --)
+ shift
+ break
+ ;;
+ -*)
+ shift
+ opts=("${opts[@]}" "$arg")
+ ;;
+ *)
+ break
+ ;;
+ esac
+ done
+
# Check and save optional first argument, number of steps upward; default
# to 1 if absent
local -i steps
@@ -27,7 +46,7 @@ ud() {
done
# Try to change into it
- cd -- "$dir"
+ cd "${opts[@]}" -- "$dir"
}
# Completion is only useful for the second argument