1 2 3 4 5 6 7 8 9 10 11 12
# Override the "cd" keyword with a copy/paste friendly function. function cd() { if [ $# -eq 0 ]; then builtin cd else if [ -f "$1" ]; then builtin cd "$(dirname "$1")" else builtin cd "$1" fi fi }