How to open Cursor from the command line

I've now switched my default coding environment to Cursor. Instead of copying and pasting my logs into ChatGPT, I use the built in chat to debug the code. It's really cool.

Here's a trick to open a directory or file in Cursor from the command

To do this, add this function to your .zshrc or .bashrc:

function cursor {
    if [[ $# = 0 ]]
    then
        open -a "Cursor"
    else
        local argPath="$1"
        [[ $1 = /* ]] && argPath="$1" || argPath="$PWD/${1#./}"
        open -a "Cursor" "$argPath"
    fi
}

That's it! Now you can open the current directory in cursor using cursor . or open a specific file using cursor file_name.