My favorite part of my zsh config

A few years ago, I thought it would be funny to have sudo cd work to cd into nonexistent directories, and so I manifested:

# in .zshrc
function sudo() {
    if [[ "$1" == "cd" ]]; then
        shift
        mkdir -p "$@"
        cd "$@"
    else
        /usr/bin/sudo "$@"
    fi
}

Used the following way:

🦒 potch@floyd : ~
» cd notreal
cd: no such file or directory: notreal

🦒 potch@floyd : ~
» sudo !!
sudo cd notreal

🦒 potch@floyd : ~/notreal
»

#dev nonsense #zsh #cli