-
Website
http://blog.jerodsanto.net/ -
Original page
http://blog.jerodsanto.net/2009/09/cd-up-up-up/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
Jerod Santo
42 comments · 3 points
-
scribu
4 comments · 2 points
-
dziegler
1 comment · 1 points
-
vitaly
2 comments · 1 points
-
imarichardson
1 comment · 1 points
-
-
Popular Threads
-
Rubular
3 weeks ago · 1 comment
-
Rubular
function cd () {
if [ ${1:0:2} == '..' ]; then
rest=${1:2}
rest=${rest//./../}
builtin cd "${1:0:2}/${rest}"
else
builtin cd "$1";
fi
}
I'm not familiar with:
${1:0:2}
What does that mean?
Your function works great in every situation except when you don't pass any args to cd at all. In this case, it fails. I added a check for that case and updated the function in the post. Let me know if it can be further improved.
Thanks!