Skip to content

Instantly share code, notes, and snippets.

@4msar
Created August 11, 2025 05:50
Show Gist options
  • Select an option

  • Save 4msar/7c8ba1d3fe247bf6043ebde194f6c504 to your computer and use it in GitHub Desktop.

Select an option

Save 4msar/7c8ba1d3fe247bf6043ebde194f6c504 to your computer and use it in GitHub Desktop.
Set default editor for development files in unix system.
#!/bin/bash
#
# Change default editor
#
function set-editor() {
# Get your editor id by this
# osascript -e 'id of app "Visual Studio Code"'
EDITOR_ID="dev.zed.Zed"
# List of file extensions relevant to software engineers
EXTENSIONS=(
"c" "cpp" "cc" "h" "hpp"
"java" "class"
"js" "jsx" "ts" "tsx"
"py" "pyw"
"rb"
"sh" "bash"
"bat" "cmd"
"go"
"php"
"swift"
"cs"
"pl" "pm"
"lua"
"kt" "kts"
"scala"
"rs"
"r"
"dart"
"xml" "json" "yml" "yaml"
"css" "scss" "sass" "less"
"md"
"sql"
"asm" "s"
"m" "mm"
"ex" "exs"
"erl"
"hs"
"lisp" "cl"
"groovy"
"fs" "fsi" "fsx"
"vue"
"coffee"
"ini" "conf" "cfg" "toml" "env"
"dockerfile" "dockerignore"
"gemspec" "gradle" "pom.xml"
"lock" "package" "yarn.lock"
"pbxproj" "xcworkspace" "xcodeproj"
"sln" "csproj" "vbproj"
"make" "mak" "mk"
"gitignore" "gitattributes"
"proto"
"f90" "f" "for"
"pas"
"adb" "ads"
"matlab"
"ps1"
"hbs"
"jade" "pug"
"ejs"
"tpl"
)
# Associate each extension with Zed using duti
for ext in "${EXTENSIONS[@]}"; do
duti -s "$EDITOR_ID" .$ext all
done
echo "All specified code file extensions are now set to open with Zed."
}
@4msar
Copy link
Author

4msar commented Aug 11, 2025

You can download this file and load in your terminal .rc file, like I used zsh so I added this line in my ~/.zshrc file.

source set-editor.sh

Then I run this command in my terminal, set-editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment