Make config/uwsm something you should never need to edit
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Set the default editor for $EDITOR
|
||||
# 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
|
||||
sed -n 's/^export EDITOR=//p' ~/.config/uwsm/default | head -n 1
|
||||
if [[ -f $editor_file ]]; then
|
||||
read -r editor <"$editor_file"
|
||||
fi
|
||||
|
||||
[[ -n $editor ]] && echo "$editor" || echo "nvim"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -24,7 +30,7 @@ nvim) editor="nvim"; name="Neovim"; glyph= ;;
|
||||
;;
|
||||
esac
|
||||
|
||||
sed -i "s/^export EDITOR=.*/export EDITOR=$editor/" ~/.config/uwsm/default
|
||||
mkdir -p "$(dirname "$editor_file")"
|
||||
printf '%s\n' "$editor" >"$editor_file"
|
||||
|
||||
export EDITOR="$editor"
|
||||
omarchy-notification-send -g $glyph "$name is now the default editor" "Effective after logging out"
|
||||
omarchy-notification-send -g $glyph "$name is now the default editor"
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Launch the default editor as determined by $EDITOR (set via ~/.config/uwsm/default) (or nvim if missing).
|
||||
# omarchy:summary=Launch the default editor selected via Omarchy defaults.
|
||||
# omarchy:args=<path>
|
||||
|
||||
omarchy-cmd-present "$EDITOR" || EDITOR=nvim
|
||||
editor_file="$HOME/.local/state/omarchy/defaults/editor"
|
||||
editor="nvim"
|
||||
|
||||
case "$EDITOR" in
|
||||
if [[ -f $editor_file ]]; then
|
||||
read -r editor <"$editor_file"
|
||||
fi
|
||||
|
||||
[[ -n $editor ]] || editor="nvim"
|
||||
omarchy-cmd-present "$editor" || editor="nvim"
|
||||
|
||||
case "${editor##*/}" in
|
||||
nvim | vim | nano | micro | hx | helix | fresh)
|
||||
exec omarchy-launch-tui "$EDITOR" "$@"
|
||||
exec omarchy-launch-tui "$editor" "$@"
|
||||
;;
|
||||
*)
|
||||
exec setsid uwsm-app -- "$EDITOR" "$@"
|
||||
exec setsid uwsm-app -- "$editor" "$@"
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user