diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2015-08-05 14:42:56 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2015-08-05 14:42:56 +1200 |
commit | 19150e2a5f4f5c1b083a4988ce801141815bf1a3 (patch) | |
tree | a1cd7d13417d8d31bfbdb26bd241bf4a1ea87d52 /bash/bashrc.d/ud.bash | |
parent | Improve comments (diff) | |
download | dotfiles-19150e2a5f4f5c1b083a4988ce801141815bf1a3.tar.gz dotfiles-19150e2a5f4f5c1b083a4988ce801141815bf1a3.zip |
Pass options to cd from ud
Diffstat (limited to 'bash/bashrc.d/ud.bash')
-rw-r--r-- | bash/bashrc.d/ud.bash | 21 |
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 |