aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2013-05-26 15:30:13 +1200
committerTom Ryder <tom@sanctum.geek.nz>2013-05-26 15:30:13 +1200
commitee7a2230536bb6ef114d3ef8c8042bff03ff9180 (patch)
tree1098b4301a8e96104a95f15a319ba7fc60efc6a6
parentExplicit env variable exports (diff)
downloaddotfiles-ee7a2230536bb6ef114d3ef8c8042bff03ff9180.tar.gz
dotfiles-ee7a2230536bb6ef114d3ef8c8042bff03ff9180.zip
Emulate zsh dir replacement feature
-rw-r--r--bash/bashrc9
1 files changed, 9 insertions, 0 deletions
diff --git a/bash/bashrc b/bash/bashrc
index 364f17ce..b65f86ff 100644
--- a/bash/bashrc
+++ b/bash/bashrc
@@ -148,6 +148,15 @@ alias gdb='gdb -q'
# I always want a unified diff.
alias diff='diff -u'
+# If given two arguments to cd, replace the first with the second in $PWD
+function cd {
+ if [[ -n "$2" ]]; then
+ builtin cd "${PWD/$1/$2}"
+ else
+ builtin cd "$*"
+ fi
+}
+
# Attach to existing tmux session rather than create a new one if possible.
function tmux {
if [[ -n "$*" ]]; then