Files
arthur-os/bin/omarchy-default-editor
T

37 lines
1.1 KiB
Bash
Executable File

#!/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:examples=omarchy default editor | omarchy default editor code | omarchy default editor helix
editor_file="$HOME/.local/state/omarchy/defaults/editor"
if (($# == 0)); then
if [[ -f $editor_file ]]; then
read -r editor <"$editor_file"
fi
[[ -n $editor ]] && echo "$editor" || echo "nvim"
exit 0
fi
case "$1" in
code) editor="code"; name="VSCode"; glyph=;;
cursor) editor="cursor"; name="Cursor"; glyph=;;
zed | zeditor) editor="zeditor"; name="Zed"; glyph=;;
sublime_text) editor="sublime_text"; name="Sublime Text"; glyph=;;
helix) editor="helix"; name="Helix"; glyph=;;
vim) editor="vim"; name="Vim"; glyph=;;
emacs) editor="emacs"; name="Emacs"; glyph=;;
nvim) editor="nvim"; name="Neovim"; glyph=;;
*)
echo "Usage: omarchy-default-editor <code|cursor|zed|sublime_text|helix|vim|emacs|nvim>"
exit 1
;;
esac
mkdir -p "$(dirname "$editor_file")"
printf '%s\n' "$editor" >"$editor_file"
omarchy-notification-send -g $glyph "$name is now the default editor"