chore(emacs): improve shell setup

This commit is contained in:
2021-05-15 22:49:52 +01:00
parent 5b0551bad8
commit d12f5f38e1
3 changed files with 41 additions and 20 deletions

View File

@@ -4,11 +4,23 @@
EMACSCLIENT="emacsclient"
ALTERNATE_EDITOR="nano"
if [ -d "/opt/emacs/bin" ] && [[ ":${PATH}:" != *":/opt/emacs/bin:"* ]]; then
export PATH="/opt/emacs/bin:$PATH"
fi
# Set to binary bundled in Emacs.app if it exists
if [ -f "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" ]; then
EMACSCLIENT="/Applications/Emacs.app/Contents/MacOS/bin/emacsclient"
if [[ "$OSTYPE" == "darwin"* ]]; then
if [ -f "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" ]; then
EMACSCLIENT="/Applications/Emacs.app/Contents/MacOS/bin/emacsclient"
fi
fi
if command -v toe &> /dev/null && toe | grep '24bit' &> /dev/null; then
FULL_COLOR_TERM="$(toe | grep '24bit' | head -n1 | awk '{ print $1 }')"
if [ -n "$FULL_COLOR_TERM" ]; then
export TERM="$FULL_COLOR_TERM"
fi
fi
# Execute emacsclient
exec env TERM=screen-24bit \
$EMACSCLIENT --alternate-editor=$ALTERNATE_EDITOR "$@"
exec $EMACSCLIENT --alternate-editor=$ALTERNATE_EDITOR "$@"

View File

@@ -2,23 +2,18 @@
# Emacs
#
# macOS systems
if [[ "$OSTYPE" == "darwin"* ]]; then
if [ -f "/Applications/Emacs.app/Contents/MacOS/Emacs" ]; then
export EMACS="/Applications/Emacs.app/Contents/MacOS/Emacs"
alias emacsgui="env TERM=screen-24bit $EMACS"
alias emacs="env TERM=screen-24bit $EMACS -nw"
fi
# Depends on EMACS and EMACSCLIENT environment variables set in ~/.zshenv
if [ -f "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" ]; then
alias emacsclient="env TERM=screen-24bit /Applications/Emacs.app/Contents/MacOS/bin/emacsclient"
fi
fi
# Linux systems
if [[ "$OSTYPE" == "linux"* ]]; then
alias emacs="env TERM=screen-24bit emacs -nw"
alias emacsclient="env TERM=screen-24bit emacsclient"
# Enforce 24-bit color mode if available
if command-exists toe && toe | grep '24bit' &> /dev/null; then
FULL_COLOR_TERM="$(toe | grep '24bit' | head -n1 | awk '{ print $1 }')"
alias emacsgui="env TERM=$FULL_COLOR_TERM $EMACS"
alias emacs="env TERM=$FULL_COLOR_TERM $EMACS -nw"
alias emacsclient="env TERM=$FULL_COLOR_TERM $EMACSCLIENT"
else
alias emacsgui="$EMACS"
alias emacs="$EMACS -nw"
alias emacsclient="$EMACSCLIENT"
fi
# add doom-emacs' bin directory to path if it exists

14
zshenv
View File

@@ -146,6 +146,20 @@ export KUBECONFIG="$HOME/.kube/config:.kube/config"
# Use custom emacs install if available
path_prepend "/opt/emacs/bin"
# Set Emacs-related environment variables
export EMACS="emacs"
export EMACSCLIENT="emacsclient"
# On macOS we want to use the Emacs.app application bundle
if [[ "$OSTYPE" == "darwin"* ]]; then
if [ -f "/Applications/Emacs.app/Contents/MacOS/Emacs" ]; then
export EMACS="/Applications/Emacs.app/Contents/MacOS/Emacs"
fi
if [ -f "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" ]; then
export EMACSCLIENT="/Applications/Emacs.app/Contents/MacOS/bin/emacsclient"
fi
fi
# Use custom tmux install if available
path_prepend "/opt/tmux/bin"