aboutsummaryrefslogblamecommitdiff
path: root/sh/profile.d/visual.sh
blob: f79158b83904a923dc20b13cccd2d487fe653389 (plain) (tree)
1
2
3
4
5
6
7
8
9

                                                                        
                                      



                                                  
                                                             
                                             








                                                                           


             

                              
             
# If an Emacs is installed, and ~/.emacs exists, use emacs as the visual
# editor; otherwise, use the system's vi
if command -v emacs >/dev/null 2>&1 &&
        [ -f "$HOME"/.emacs ] ; then

    # Use or start a GNU Emacs client, if possible
    if command -v pgrep >/dev/null 2>&1 &&
            pgrep -fxu "$USER" 'emacs --daemon' >/dev/null ||
            emacs --daemon 2>/dev/null ; then
        VISUAL=emacsclient

    # If no GNU Emacs daemon is available, just create a new instance every
    # time
    else
        VISUAL=emacs
    fi

# If an Emacs isn't installed, just use good old vi
else
    VISUAL=vi
fi

# Export final editor decision
export VISUAL