-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe
executable file
·71 lines (65 loc) · 2.02 KB
/
e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh
# SH FILE: e
#
# Purpose : Start Emacs in terminal mode. Support multiple environments
# Created : Wednesday, May 22 2024.
# Author : Pierre Rouleau <[email protected]>
# Time-stamp: <2024-12-18 22:57:40 EST, updated by Pierre Rouleau>
# ----------------------------------------------------------------------------
# Module Description
# ------------------
#
# Launch emacs inside the current terminal shell in terminal mode.
# Prompt if being launched from inside an Emacs shell/terminal buffer.
#
# Note: if you want to execute the script under sudo, you will most likely
# need to provide the exact path to the script.
# ----------------------------------------------------------------------------
# Dependencies
# ------------
#
# - Emacs must be installed, accessible as 'emacs'.
# - That version of Emacs must support the terminal mode with the `-nw`
# command line option.
# - Additionally, under macOS, no NOT use the cocoa/GUI built version of Emacs;
# it will work but it takes much more time to start, probably loading GUI library
# files not needed by the terminal mode version of Emacs.
#
# ----------------------------------------------------------------------------
# Code
# ----
#
#
# Check if already inside Emacs and prompt whether to continue
prompt_yn_return=
prompt_yn()
{
# Arg 1: string prompt
while true; do
printf "%s [yn]? " "$1"
read -r yn
case $yn in
[Yy]* )
prompt_yn_return=y
break
;;
[Nn]* )
prompt_yn_return=n
break
;;
* ) echo "Please answer yes or no.";;
esac
done
}
if [ -z "$INSIDE_EMACS" ]; then
emacs -nw "$@"
else
printf -- "ALREADY inside Emacs!\n"
prompt_yn "Invoke another terminal-based Emacs inside this Emacs shell anyway"
if [ "$prompt_yn_return" = "y" ]; then
emacs -nw "$@"
else
exit 1
fi
fi
# ----------------------------------------------------------------------------