Created
August 11, 2025 05:50
-
-
Save 4msar/7c8ba1d3fe247bf6043ebde194f6c504 to your computer and use it in GitHub Desktop.
Set default editor for development files in unix system.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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." | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can download this file and load in your terminal .rc file, like I used zsh so I added this line in my
~/.zshrcfile.source set-editor.shThen I run this command in my terminal,
set-editor.