diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-19 12:48:35 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-19 12:48:35 +1200 |
commit | 3d8cf05dfc685e799aa5e20319e8e33288e74e04 (patch) | |
tree | 28668e9ba83860c7a30cea5a2c5b80533121ae39 /bash | |
parent | Flag issue fixed (diff) | |
download | dotfiles-3d8cf05dfc685e799aa5e20319e8e33288e74e04.tar.gz dotfiles-3d8cf05dfc685e799aa5e20319e8e33288e74e04.zip |
Change cd() into POSIX shell script
Diffstat (limited to '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 -} |