diff options
Diffstat (limited to 'bash/bashrc.d/cd.bash')
-rw-r--r-- | bash/bashrc.d/cd.bash | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/bash/bashrc.d/cd.bash b/bash/bashrc.d/cd.bash deleted file mode 100644 index 04de96d5..00000000 --- a/bash/bashrc.d/cd.bash +++ /dev/null @@ -1,32 +0,0 @@ -# If given two arguments to cd, replace the first with the second in $PWD, -# emulating a Zsh function that I often find useful; preserves options too -cd() { - local arg - local -a opts - for arg ; do - case $arg in - --) - shift - break - ;; - -*) - shift - opts[${#opts[@]}]=$arg - ;; - *) - break - ;; - esac - done - if (($# == 2)) ; then - if [[ $PWD == *"$1"* ]] ; then - builtin cd "${opts[@]}" -- "${PWD/"$1"/"$2"}" - else - printf 'bash: %s: could not replace substring\n' \ - "$FUNCNAME" >&2 - return 2 - fi - else - builtin cd "${opts[@]}" -- "$@" - fi -} |