Add emacs console helper scripts
This commit is contained in:
126
bin/README.md
Normal file
126
bin/README.md
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
# Emacs Console Helper Scripts
|
||||||
|
|
||||||
|
Collection of helper scripts to launch Emacs in terminal mode (`-nw`) with specific configurations.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Add this directory to your PATH:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export PATH="$HOME/.emacs.d/bin:$PATH"
|
||||||
|
```
|
||||||
|
|
||||||
|
Add to your shell configuration file (`~/.bashrc`, `~/.zshrc`, etc.) to make it permanent.
|
||||||
|
|
||||||
|
## Main Launcher
|
||||||
|
|
||||||
|
### `em` - Universal Emacs launcher
|
||||||
|
|
||||||
|
The main entry point for all modes. Usage:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
em [mode] [args...]
|
||||||
|
```
|
||||||
|
|
||||||
|
Without arguments, launches standard Emacs in terminal mode.
|
||||||
|
|
||||||
|
## Available Modes
|
||||||
|
|
||||||
|
### Email
|
||||||
|
```bash
|
||||||
|
em mail # Launch mu4e email client
|
||||||
|
```
|
||||||
|
|
||||||
|
### RSS Feeds
|
||||||
|
```bash
|
||||||
|
em feeds # Launch Elfeed RSS reader
|
||||||
|
```
|
||||||
|
|
||||||
|
### Development
|
||||||
|
```bash
|
||||||
|
em dev # Launch with development environment
|
||||||
|
em dev project/ # Open specific project in dev mode
|
||||||
|
```
|
||||||
|
|
||||||
|
### Git
|
||||||
|
```bash
|
||||||
|
em magit # Launch Magit in current directory
|
||||||
|
em magit /path/to/repo # Launch Magit in specific repository
|
||||||
|
```
|
||||||
|
|
||||||
|
### File Comparison
|
||||||
|
```bash
|
||||||
|
em compare file1 file2 # Compare two files using ediff
|
||||||
|
```
|
||||||
|
|
||||||
|
### File Manager
|
||||||
|
```bash
|
||||||
|
em dired # Launch Dired in current directory
|
||||||
|
em dired /path/to/dir # Launch Dired in specific directory
|
||||||
|
```
|
||||||
|
|
||||||
|
### Portfolio Tracker
|
||||||
|
```bash
|
||||||
|
em portfolio # Launch portfolio tracker
|
||||||
|
```
|
||||||
|
|
||||||
|
### Org Mode
|
||||||
|
```bash
|
||||||
|
em org # Launch Org agenda
|
||||||
|
em org notes.org # Open/create specific org file
|
||||||
|
```
|
||||||
|
|
||||||
|
### Terminal
|
||||||
|
```bash
|
||||||
|
em terminal # Launch terminal emulator in Emacs
|
||||||
|
```
|
||||||
|
|
||||||
|
### Quick Mode
|
||||||
|
```bash
|
||||||
|
em quick # Launch without configuration (emacs -Q)
|
||||||
|
em quick file.txt # Quick edit without loading config
|
||||||
|
```
|
||||||
|
|
||||||
|
## Individual Scripts
|
||||||
|
|
||||||
|
You can also use the scripts directly:
|
||||||
|
|
||||||
|
- `emacs-mail` - Email client
|
||||||
|
- `emacs-feeds` - RSS reader
|
||||||
|
- `emacs-dev` - Development environment
|
||||||
|
- `emacs-magit` - Git interface
|
||||||
|
- `emacs-compare` - File comparison
|
||||||
|
- `emacs-dired` - File manager
|
||||||
|
- `emacs-portfolio` - Portfolio tracker
|
||||||
|
- `emacs-org` - Org mode
|
||||||
|
- `emacs-terminal` - Terminal emulator
|
||||||
|
- `emacs-quick` - Quick mode without config
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Quick email check
|
||||||
|
em mail
|
||||||
|
|
||||||
|
# Work on a project
|
||||||
|
em dev ~/projects/myapp
|
||||||
|
|
||||||
|
# Compare configuration files
|
||||||
|
em compare config.old config.new
|
||||||
|
|
||||||
|
# Quick file edit without loading full config
|
||||||
|
em quick /etc/hosts
|
||||||
|
|
||||||
|
# Manage git repository
|
||||||
|
em magit ~/projects/myapp
|
||||||
|
|
||||||
|
# Browse files
|
||||||
|
em dired ~/Documents
|
||||||
|
```
|
||||||
|
|
||||||
|
## Tips
|
||||||
|
|
||||||
|
- Use `em quick` for system file edits or when you need fast startup
|
||||||
|
- The dev mode automatically enables modern development features and Treemacs
|
||||||
|
- All modes support standard Emacs command-line arguments
|
||||||
|
- Scripts preserve terminal mode (`-nw`) for console usage
|
||||||
85
bin/em
Executable file
85
bin/em
Executable file
@@ -0,0 +1,85 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Main Emacs launcher with mode selection
|
||||||
|
# Usage: em [mode] [args...]
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(dirname "$0")"
|
||||||
|
|
||||||
|
show_help() {
|
||||||
|
cat << EOF
|
||||||
|
Emacs Terminal Mode Launcher
|
||||||
|
|
||||||
|
Usage: em [mode] [args...]
|
||||||
|
|
||||||
|
Available modes:
|
||||||
|
mail - Launch mu4e email client
|
||||||
|
feeds - Launch Elfeed RSS reader
|
||||||
|
dev - Launch development environment with Treemacs
|
||||||
|
magit - Launch Magit git interface
|
||||||
|
compare - Compare two files with ediff
|
||||||
|
dired - Launch Dired file manager
|
||||||
|
portfolio - Launch portfolio tracker
|
||||||
|
org - Launch Org mode
|
||||||
|
terminal - Launch terminal emulator in Emacs
|
||||||
|
quick - Quick mode without config (emacs -Q)
|
||||||
|
help - Show this help message
|
||||||
|
|
||||||
|
Without mode argument, launches standard Emacs in terminal.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
em # Launch standard Emacs
|
||||||
|
em mail # Launch email client
|
||||||
|
em dev myproject/ # Open project in dev mode
|
||||||
|
em compare f1.txt f2.txt # Compare two files
|
||||||
|
em magit /path/to/repo # Open Magit in specific repo
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
# No arguments, launch standard emacs
|
||||||
|
emacs -nw
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
MODE=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
case "$MODE" in
|
||||||
|
mail)
|
||||||
|
exec "$SCRIPT_DIR/emacs-mail" "$@"
|
||||||
|
;;
|
||||||
|
feeds)
|
||||||
|
exec "$SCRIPT_DIR/emacs-feeds" "$@"
|
||||||
|
;;
|
||||||
|
dev)
|
||||||
|
exec "$SCRIPT_DIR/emacs-dev" "$@"
|
||||||
|
;;
|
||||||
|
magit)
|
||||||
|
exec "$SCRIPT_DIR/emacs-magit" "$@"
|
||||||
|
;;
|
||||||
|
compare)
|
||||||
|
exec "$SCRIPT_DIR/emacs-compare" "$@"
|
||||||
|
;;
|
||||||
|
dired)
|
||||||
|
exec "$SCRIPT_DIR/emacs-dired" "$@"
|
||||||
|
;;
|
||||||
|
portfolio)
|
||||||
|
exec "$SCRIPT_DIR/emacs-portfolio" "$@"
|
||||||
|
;;
|
||||||
|
org)
|
||||||
|
exec "$SCRIPT_DIR/emacs-org" "$@"
|
||||||
|
;;
|
||||||
|
terminal)
|
||||||
|
exec "$SCRIPT_DIR/emacs-terminal" "$@"
|
||||||
|
;;
|
||||||
|
quick)
|
||||||
|
exec "$SCRIPT_DIR/emacs-quick" "$@"
|
||||||
|
;;
|
||||||
|
help|--help|-h)
|
||||||
|
show_help
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# Unknown mode, treat as file argument
|
||||||
|
emacs -nw "$MODE" "$@"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
25
bin/emacs-compare
Executable file
25
bin/emacs-compare
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Launch Emacs in terminal mode for file comparison (ediff)
|
||||||
|
# Usage: emacs-compare file1 file2
|
||||||
|
|
||||||
|
if [ $# -ne 2 ]; then
|
||||||
|
echo "Usage: $0 file1 file2"
|
||||||
|
echo "Compare two files using Emacs ediff"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$1" ]; then
|
||||||
|
echo "Error: File $1 does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$2" ]; then
|
||||||
|
echo "Error: File $2 does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
FILE1=$(realpath "$1")
|
||||||
|
FILE2=$(realpath "$2")
|
||||||
|
|
||||||
|
EMACS_NO_DESKTOP=1 emacs -nw --eval "(progn
|
||||||
|
(ediff-files \"$FILE1\" \"$FILE2\"))"
|
||||||
19
bin/emacs-dev
Executable file
19
bin/emacs-dev
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Launch Emacs in terminal mode with development environment
|
||||||
|
# Accepts optional file/directory argument
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
# No arguments, just start with dev mode
|
||||||
|
EMACS_NO_DESKTOP=1 emacs -nw --eval "(progn
|
||||||
|
(when (fboundp 'enable-dev-mode-modern)
|
||||||
|
(enable-dev-mode-modern))
|
||||||
|
(when (fboundp 'treemacs)
|
||||||
|
(treemacs)))"
|
||||||
|
else
|
||||||
|
# Open specified file/directory
|
||||||
|
EMACS_NO_DESKTOP=1 emacs -nw "$@" --eval "(progn
|
||||||
|
(when (fboundp 'enable-dev-mode-modern)
|
||||||
|
(enable-dev-mode-modern))
|
||||||
|
(when (fboundp 'treemacs)
|
||||||
|
(treemacs)))"
|
||||||
|
fi
|
||||||
17
bin/emacs-dired
Executable file
17
bin/emacs-dired
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Launch Emacs in terminal mode with Dired file manager
|
||||||
|
# Accepts optional directory argument
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
# No arguments, use current directory
|
||||||
|
EMACS_NO_DESKTOP=1 emacs -nw --eval "(dired \".\")"
|
||||||
|
else
|
||||||
|
# Use specified directory
|
||||||
|
if [ -d "$1" ]; then
|
||||||
|
DIR=$(realpath "$1")
|
||||||
|
EMACS_NO_DESKTOP=1 emacs -nw --eval "(dired \"$DIR\")"
|
||||||
|
else
|
||||||
|
echo "Error: $1 is not a directory"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
7
bin/emacs-feeds
Executable file
7
bin/emacs-feeds
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Launch Emacs in terminal mode with Elfeed RSS reader
|
||||||
|
|
||||||
|
EMACS_NO_DESKTOP=1 emacs -nw --eval "(progn
|
||||||
|
(require 'elfeed nil t)
|
||||||
|
(elfeed)
|
||||||
|
(elfeed-update))"
|
||||||
29
bin/emacs-magit
Executable file
29
bin/emacs-magit
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Launch Emacs in terminal mode with Magit git interface
|
||||||
|
# Accepts optional repository path argument
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
# No arguments, use current directory
|
||||||
|
EMACS_NO_DESKTOP=1 emacs -nw --eval "(progn
|
||||||
|
(require 'package)
|
||||||
|
(package-initialize)
|
||||||
|
(unless (package-installed-p 'magit)
|
||||||
|
(package-refresh-contents)
|
||||||
|
(package-install 'magit))
|
||||||
|
(require 'magit)
|
||||||
|
(magit-status))"
|
||||||
|
else
|
||||||
|
# Use specified directory
|
||||||
|
cd "$1" 2>/dev/null || {
|
||||||
|
echo "Error: Cannot access directory $1"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
EMACS_NO_DESKTOP=1 emacs -nw --eval "(progn
|
||||||
|
(require 'package)
|
||||||
|
(package-initialize)
|
||||||
|
(unless (package-installed-p 'magit)
|
||||||
|
(package-refresh-contents)
|
||||||
|
(package-install 'magit))
|
||||||
|
(require 'magit)
|
||||||
|
(magit-status))"
|
||||||
|
fi
|
||||||
6
bin/emacs-mail
Executable file
6
bin/emacs-mail
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Launch Emacs in terminal mode with mu4e email client
|
||||||
|
|
||||||
|
EMACS_NO_DESKTOP=1 emacs -nw --eval "(progn
|
||||||
|
(require 'mu4e nil t)
|
||||||
|
(mu4e))"
|
||||||
20
bin/emacs-org
Executable file
20
bin/emacs-org
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Launch Emacs in terminal mode with Org mode
|
||||||
|
# Accepts optional org file argument
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
# No arguments, start with org-agenda
|
||||||
|
EMACS_NO_DESKTOP=1 emacs -nw --eval "(progn
|
||||||
|
(require 'org)
|
||||||
|
(org-agenda))"
|
||||||
|
else
|
||||||
|
# Open specified org file
|
||||||
|
if [ -f "$1" ]; then
|
||||||
|
EMACS_NO_DESKTOP=1 emacs -nw "$1" --eval "(org-mode)"
|
||||||
|
else
|
||||||
|
# Create new org file
|
||||||
|
EMACS_NO_DESKTOP=1 emacs -nw "$1" --eval "(progn
|
||||||
|
(org-mode)
|
||||||
|
(insert \"#+TITLE: $(basename \"$1\" .org)\n#+DATE: $(date +%Y-%m-%d)\n\n\"))"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
6
bin/emacs-portfolio
Executable file
6
bin/emacs-portfolio
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Launch Emacs in terminal mode with portfolio tracker
|
||||||
|
|
||||||
|
EMACS_NO_DESKTOP=1 emacs -nw --eval "(progn
|
||||||
|
(when (fboundp 'portfolio-tracker)
|
||||||
|
(portfolio-tracker)))"
|
||||||
5
bin/emacs-quick
Executable file
5
bin/emacs-quick
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Launch Emacs in terminal mode with minimal startup (quick mode)
|
||||||
|
# Useful for quick edits without loading full configuration
|
||||||
|
|
||||||
|
emacs -nw -Q "$@"
|
||||||
22
bin/emacs-terminal
Executable file
22
bin/emacs-terminal
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Launch Emacs in terminal mode with built-in terminal emulator
|
||||||
|
# Accepts optional shell command argument
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
# No arguments, start default shell
|
||||||
|
EMACS_NO_DESKTOP=1 emacs -nw --eval "(progn
|
||||||
|
(if (fboundp 'vterm)
|
||||||
|
(vterm)
|
||||||
|
(if (fboundp 'term)
|
||||||
|
(term (getenv \"SHELL\"))
|
||||||
|
(eshell))))"
|
||||||
|
else
|
||||||
|
# Run specified command
|
||||||
|
CMD="$*"
|
||||||
|
EMACS_NO_DESKTOP=1 emacs -nw --eval "(progn
|
||||||
|
(if (fboundp 'vterm)
|
||||||
|
(vterm)
|
||||||
|
(if (fboundp 'term)
|
||||||
|
(term \"$CMD\")
|
||||||
|
(eshell))))"
|
||||||
|
fi
|
||||||
6
init.el
6
init.el
@@ -11,10 +11,10 @@
|
|||||||
|
|
||||||
;; EMERGENCY FIX - Load this first to ensure editing works
|
;; EMERGENCY FIX - Load this first to ensure editing works
|
||||||
(require 'init-emergency-fix)
|
(require 'init-emergency-fix)
|
||||||
(require 'init-seq-fix) ; Fix seq library issues
|
;; (require 'init-seq-fix) ; Fix seq library issues
|
||||||
|
|
||||||
;; Load performance optimizations early
|
;; Load performance optimizations early
|
||||||
(require 'init-performance)
|
;; (require 'init-performance)
|
||||||
|
|
||||||
;;; Load core modules in order
|
;;; Load core modules in order
|
||||||
(require 'init-core) ; Core settings and package management
|
(require 'init-core) ; Core settings and package management
|
||||||
@@ -165,4 +165,4 @@
|
|||||||
"Default portfolio file to load.")
|
"Default portfolio file to load.")
|
||||||
|
|
||||||
(provide 'init)
|
(provide 'init)
|
||||||
;;; init.el ends here
|
;;; init.el ends here
|
||||||
|
|||||||
@@ -133,21 +133,23 @@
|
|||||||
(setq desktop-lazy-verbose nil)
|
(setq desktop-lazy-verbose nil)
|
||||||
(setq desktop-lazy-idle-delay 1) ; Restore rest after 1 second idle
|
(setq desktop-lazy-idle-delay 1) ; Restore rest after 1 second idle
|
||||||
|
|
||||||
;; Enable desktop-save-mode after startup
|
;; Enable desktop-save-mode after startup (unless disabled via environment)
|
||||||
(add-hook 'after-init-hook
|
(add-hook 'after-init-hook
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(desktop-save-mode 1)
|
;; Check if desktop mode should be disabled (for helper scripts)
|
||||||
(setq desktop-save t)
|
(unless (getenv "EMACS_NO_DESKTOP")
|
||||||
(setq desktop-auto-save-timeout 300)
|
(desktop-save-mode 1)
|
||||||
(setq desktop-path '("~/.emacs.d/"))
|
(setq desktop-save t)
|
||||||
(setq desktop-dirname "~/.emacs.d/")
|
(setq desktop-auto-save-timeout 300)
|
||||||
(setq desktop-base-file-name "emacs-desktop")
|
(setq desktop-path '("~/.emacs.d/"))
|
||||||
(setq desktop-restore-frames t)
|
(setq desktop-dirname "~/.emacs.d/")
|
||||||
;; Load desktop after a delay
|
(setq desktop-base-file-name "emacs-desktop")
|
||||||
(run-with-idle-timer 2 nil
|
(setq desktop-restore-frames t)
|
||||||
(lambda ()
|
;; Load desktop after a delay
|
||||||
(desktop-read)
|
(run-with-idle-timer 2 nil
|
||||||
(message "Desktop restored")))))
|
(lambda ()
|
||||||
|
(desktop-read)
|
||||||
|
(message "Desktop restored"))))))
|
||||||
|
|
||||||
(provide 'init-core)
|
(provide 'init-core)
|
||||||
;;; init-core.el ends here
|
;;; init-core.el ends here
|
||||||
Reference in New Issue
Block a user