]> arthur.barton.de Git - ax-zsh.git/blob - plugins/editor_select/editor_select.zprofile
P10k: Read config after enabling instant prompt
[ax-zsh.git] / plugins / editor_select / editor_select.zprofile
1 # AX-ZSH: Alex' Modular ZSH Configuration
2 # editor_select.zprofile: Setup $EDITOR for the "best" available editor
3
4 if [[ -z "$EDITOR" ]]; then
5         if [[ -n "$DISPLAY" ]]; then
6                 # X11 available, consider X11-based editors, too!
7                 x11_editors="gvim"
8         fi
9
10         for editor (
11                 code atom mate subl mvim
12                 $x11_editors
13                 vim nano joe vi
14         ); do
15                 if [ -n "$commands[$editor]" ]; then
16                         EDITOR="$commands[$editor]"
17                         break
18                 fi
19         done
20         unset editor x11_editors
21 fi
22
23 case "$EDITOR:t" in
24         "code"|"atom"|"mate"|"subl")
25                 EDITOR="$EDITOR --wait"
26                 ;;
27         "mvim"|"gvim")
28                 EDITOR="$EDITOR --nofork"
29                 ;;
30 esac
31
32 if [[ -n "$EDITOR" ]]; then
33         export EDITOR
34         alias zshenv="$EDITOR ~/.zshenv"
35 fi