summaryrefslogtreecommitdiffstats
path: root/.bashrc
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2013-08-22 19:01:51 +0200
committerJan Pokorný <jpokorny@redhat.com>2013-08-22 19:01:51 +0200
commitc49882e7943d20327319bf7d3223927aad9cf126 (patch)
treeab56ba0160d68817c0608ae249e890aad2a3f957 /.bashrc
parent06186d3f3084b00a3c9f025d7fa3ca772c642493 (diff)
downloaddotfiles-c49882e7943d20327319bf7d3223927aad9cf126.tar.gz
dotfiles-c49882e7943d20327319bf7d3223927aad9cf126.tar.xz
dotfiles-c49882e7943d20327319bf7d3223927aad9cf126.zip
Bash config: define and use diralias helper
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to '.bashrc')
-rw-r--r--.bashrc13
1 files changed, 10 insertions, 3 deletions
diff --git a/.bashrc b/.bashrc
index cb5305a..b3bf876 100644
--- a/.bashrc
+++ b/.bashrc
@@ -24,9 +24,16 @@ alias acka='ack -a --follow'
# debug, etc.
alias hist-del-last='history -d $(history 1 | cut -d" " -f2)' # historical NOOP
-# proper aliases
-alias gmy="pushd ~/wrkspc/gmy >/dev/null"
-alias gwork="pushd ~/wrkspc/gwork >/dev/null"
+# dir aliases (use either as "gmy" or "rd $(gmy)")
+_diralias () {
+ test "$(pwd)" = "$(eval echo "$(dirs +1)")" && popd -n &>/dev/null
+ test "$1" = "$(eval echo "$(dirs +0)")" || pushd "$1" >/dev/null
+ pwd
+}
+diralias () { alias "$(basename "$1")=_diralias $1"; }
+
+diralias ~/wrkspc/gmy
+diralias ~/wrkspc/gwork
# debug, etc.