DEV Community

Yunus Emre Ak
Yunus Emre Ak

Posted on Originally published at docs.yemreak.com

Set Cursor as Default Editor on macOS (Instead of Xcode)

Set Cursor as Default Editor on macOS (Instead of Xcode)

Backup

mkdir -p ~/backup_defaults
defaults read com.apple.LaunchServices/com.apple.launchservices.secure > ~/backup_defaults/launch_services_$(date +%Y%m%d_%H%M%S).plist

for ext in json py js ts tsx md txt sh yml yaml toml c cpp java go rb php html css; do
  current=$(duti -x .$ext 2>/dev/null | head -1)
  [ ! -z "$current" ] && echo ".$ext: $current" >> ~/backup_defaults/duti_backup_$(date +%Y%m%d_%H%M%S).txt
done
Enter fullscreen mode Exit fullscreen mode

Cursor ID

osascript -e 'id of app "Cursor"'
# com.todesktop.230313mzl4w4u92
Enter fullscreen mode Exit fullscreen mode

duti

brew install duti
Enter fullscreen mode Exit fullscreen mode

File Types

CURSOR_ID="com.todesktop.230313mzl4w4u92"

# General
duti -s $CURSOR_ID public.json all
duti -s $CURSOR_ID public.plain-text all
duti -s $CURSOR_ID public.python-script all
duti -s $CURSOR_ID public.shell-script all
duti -s $CURSOR_ID public.source-code all
duti -s $CURSOR_ID public.text all
duti -s $CURSOR_ID public.unix-executable all
duti -s $CURSOR_ID public.data all

# Extensions
for ext in c cpp cs css go java js sass scss less vue cfg json jsx log lua md php pl py rb ts tsx txt conf yaml yml toml xml svg; do
  duti -s $CURSOR_ID .$ext all
done
Enter fullscreen mode Exit fullscreen mode

Shell & Git

echo 'export EDITOR="cursor"' >> ~/.zshrc
echo 'export VISUAL="cursor"' >> ~/.zshrc
git config --global core.editor "cursor --wait"
Enter fullscreen mode Exit fullscreen mode

Verify

duti -x .py
duti -x .js
duti -x .md
Enter fullscreen mode Exit fullscreen mode

Read the original: Set Cursor as Default Editor on macOS (Instead of Xcode)

Top comments (0)