Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions bin/omarchy-default-editor
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# omarchy:summary=Set the default editor used by omarchy-launch-editor
# omarchy:args=[code|cursor|zed|sublime_text|helix|vim|emacs|nvim]
# omarchy:args=[code|cursor|zed|sublime_text|subl|helix|vim|emacs|nvim]
# omarchy:examples=omarchy default editor | omarchy default editor code | omarchy default editor helix

installing=false
Expand All @@ -17,6 +17,9 @@ if (($# == 0)); then
read -r editor <"$editor_file"
fi

# sublime-text-4 puts `subl` on PATH, not the desktop id sublime_text.
[[ $editor == "sublime_text" ]] && editor="subl"

[[ -n $editor ]] && echo "$editor" || echo "nvim"
exit 0
fi
Expand All @@ -25,13 +28,13 @@ case "$1" in
code) selection="code"; editor="code"; name="VSCode"; glyph= ;;
cursor) selection="cursor"; editor="cursor"; name="Cursor"; glyph= ;;
zed | zeditor) selection="zed"; editor="zeditor"; name="Zed"; glyph= ;;
sublime_text) selection="sublime_text"; editor="sublime_text"; name="Sublime Text"; glyph= ;;
sublime_text | subl) selection="sublime_text"; editor="subl"; name="Sublime Text"; glyph= ;;
helix) selection="helix"; editor="helix"; name="Helix"; glyph= ;;
vim) selection="vim"; editor="vim"; name="Vim"; glyph= ;;
emacs) selection="emacs"; editor="emacs"; name="Emacs"; glyph= ;;
nvim) selection="nvim"; editor="nvim"; name="Neovim"; glyph= ;;
*)
echo "Usage: omarchy-default-editor <code|cursor|zed|sublime_text|helix|vim|emacs|nvim>"
echo "Usage: omarchy-default-editor <code|cursor|zed|sublime_text|subl|helix|vim|emacs|nvim>"
exit 1
;;
esac
Expand Down
3 changes: 3 additions & 0 deletions bin/omarchy-launch-editor
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ else
editor="nvim"
fi

# sublime-text-4 puts `subl` on PATH, not the desktop id sublime_text.
[[ $editor == "sublime_text" ]] && editor="subl"

omarchy-cmd-present "$editor" || editor="nvim"

case "${editor##*/}" in
Expand Down
2 changes: 1 addition & 1 deletion default/omarchy/omarchy-menu.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
"setup.default.editor.vscode": {"icon":"","label":"VSCode","checked":"[[ \"$(omarchy-default-editor)\" == \"code\" ]]","action":"omarchy-default-editor code"},
"setup.default.editor.cursor": {"icon":"","label":"Cursor","checked":"[[ \"$(omarchy-default-editor)\" == \"cursor\" ]]","action":"omarchy-default-editor cursor"},
"setup.default.editor.zed": {"icon":"","label":"Zed","checked":"[[ \"$(omarchy-default-editor)\" == \"zeditor\" ]]","action":"omarchy-default-editor zed"},
"setup.default.editor.sublime": {"icon":"","label":"Sublime Text","checked":"[[ \"$(omarchy-default-editor)\" == \"sublime_text\" ]]","action":"omarchy-default-editor sublime_text"},
"setup.default.editor.sublime": {"icon":"","label":"Sublime Text","checked":"[[ \"$(omarchy-default-editor)\" == \"subl\" ]]","action":"omarchy-default-editor sublime_text"},
"setup.default.editor.helix": {"icon":"","label":"Helix","checked":"[[ \"$(omarchy-default-editor)\" == \"helix\" ]]","action":"omarchy-default-editor helix"},
"setup.default.editor.vim": {"icon":"","label":"Vim","checked":"[[ \"$(omarchy-default-editor)\" == \"vim\" ]]","action":"omarchy-default-editor vim"},
"setup.default.editor.emacs": {"icon":"","label":"Emacs","checked":"[[ \"$(omarchy-default-editor)\" == \"emacs\" ]]","action":"omarchy-default-editor emacs"},
Expand Down
11 changes: 9 additions & 2 deletions test/shell.d/default-apps-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ omarchy-pkg-add|omarchy-pkg-aur-add)
firefox) command=firefox ;;
zen-browser-bin) command=zen-browser ;;
cursor-bin) command=cursor ;;
sublime-text-4) command=sublime_text ;;
sublime-text-4) command=subl ;;
vim) command=vim ;;
neovim) command=nvim ;;
esac
Expand Down Expand Up @@ -169,7 +169,7 @@ editor_cases=(
'code code editor:vscode'
'cursor cursor pkg:cursor-bin'
'zed zeditor editor:zed'
'sublime_text sublime_text pkg:sublime-text-4'
'sublime_text subl pkg:sublime-text-4'
'helix helix editor:helix'
'vim vim pkg:vim'
'emacs emacs editor:emacs'
Expand Down Expand Up @@ -297,6 +297,13 @@ for entry in "${editor_cases[@]}"; do
done
pass "editor defaults install every missing editor before selection"

mkdir -p "$test_home/.local/state/omarchy/defaults"
printf '%s\n' sublime_text >"$test_home/.local/state/omarchy/defaults/editor"
touch "$installed_dir/subl"
[[ $(omarchy-default-editor) == subl ]] || fail "stored sublime_text reports as subl"
pass "legacy sublime_text default reports as subl"


: >"$install_log"
: >"$terminal_log"
omarchy-default-browser zen
Expand Down