diff options
Diffstat (limited to 'bash/bashrc.d/cd.bash')
-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 |