diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2013-11-04 17:54:23 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2013-11-04 17:54:23 +1300 |
commit | b4567bcefd8cc1992b042b209ac15fcc41d5bb05 (patch) | |
tree | 45c5e344e99565b6277502d1818cba0c2098ebd7 | |
parent | More general approach to options for cd wrapper (diff) | |
download | dotfiles-b4567bcefd8cc1992b042b209ac15fcc41d5bb05.tar.gz dotfiles-b4567bcefd8cc1992b042b209ac15fcc41d5bb05.zip |
Forgot to stop using absolute params
-rw-r--r-- | bash/bashrc.d/cd.bash | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/bash/bashrc.d/cd.bash b/bash/bashrc.d/cd.bash index 72a3fe0b..fa027e52 100644 --- a/bash/bashrc.d/cd.bash +++ b/bash/bashrc.d/cd.bash @@ -12,9 +12,10 @@ cd() { dirs=("${dirs[@]}" "$arg") fi done - if (($# == 2)); then - if [[ $PWD == *"$1"* ]]; then - builtin cd "${opts[@]}" "${PWD/$1/$2}" + if ((${#dirs} == 2)); then + if [[ $PWD == *"${dirs[0]}"* ]]; then + builtin cd "${opts[@]}" \ + "${PWD/${dirs[0]}/${dirs[1]}}" else printf '%s\n' 'bash: cd: could not replace substring' >&2 return 1 |