From b4e6518f7eff38d57d2ce5500fb6292d90e000f6 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 16 Jan 2023 12:46:27 -0600 Subject: KEY SMASHSHHHH --- lisp/acdw-shell | 0 lisp/acdw-shell.el | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++ lisp/acdw-web.el | 28 +++++++++++ 3 files changed, 169 insertions(+) create mode 100644 lisp/acdw-shell create mode 100644 lisp/acdw-shell.el create mode 100644 lisp/acdw-web.el (limited to 'lisp') diff --git a/lisp/acdw-shell b/lisp/acdw-shell new file mode 100644 index 0000000..e69de29 diff --git a/lisp/acdw-shell.el b/lisp/acdw-shell.el new file mode 100644 index 0000000..7c542aa --- /dev/null +++ b/lisp/acdw-shell.el @@ -0,0 +1,141 @@ +;;; acdw-shell.el ---Shell config -*- lexical-binding: t; -*- + +;;; Code: + +(defvar eshell-buffer-format "*eshell:%s*" + "Format for eshell buffer names.") + +(defun eshell-rename-pwd () + (rename-buffer (format eshell-buffer-format default-directory) t)) + +(defun eshell-last-dir () + (goto-char (point-max)) + (insert "cd -") + (eshell-send-input)) + +(defun eshellp (buffer-or-name) + (with-current-buffer buffer-or-name + (derived-mode-p 'eshell-mode))) + +(defun +eshell (&optional new) + (interactive "P") + (let ((dir default-directory) + (bname (format eshell-buffer-format default-directory)) + (display-comint-buffer-action 'pop-to-buffer)) + (if-let ((buf (and (not new) + (or (get-buffer bname) + (seq-find #'eshellp + (reverse (buffer-list))))))) + (pop-to-buffer buf) + (eshell new)) + (eshell-rename-pwd) + (unless (equal default-directory dir) + (eshell/cd dir) + (eshell-send-input) + (goto-char (point-max))))) + +(defun +eshell-quit (&optional choose) + (interactive "P") + (if choose + (let* ((bufs (mapcar #'buffer-name + (seq-filter #'eshellp + (buffer-list)))) + (buf (get-buffer + (completing-read "Eshell: " + bufs nil t nil nil (car bufs))))) + (quit-window) + (pop-to-buffer buf)) + (quit-window))) + +(defun acdw/eshell-prompt () + "My custom eshell prompt." + (concat (if (= 0 eshell-last-command-status) + "^_^ " + ";_; ") + (abbreviate-file-name (eshell/pwd)) + (if (= (user-uid) 0) " # " " $ "))) + + +;;; Packages + +(use-package eshell + :init + (add-hook 'eshell-post-command-hook #'eshell-rename-pwd) + (setopt eshell-modules-list + '(eshell-alias + eshell-basic + eshell-cmpl + eshell-dirs + eshell-elecslash + eshell-hist + eshell-ls + eshell-prompt + eshell-smart + eshell-extpipe + eshell-glob + eshell-hist + eshell-ls + eshell-pred + eshell-prompt + eshell-script + eshell-term + eshell-unix)) + :commands eshell + :bind (("C-z" . +eshell) + :map eshell-mode-map + ("C-z" . +eshell-quit) + ("C-o" . eshell-last-dir)) + :config + (require 'esh-module) + (require 'em-smart) + (require 'em-tramp) + (setopt eshell-destroy-buffer-when-process-dies t + eshell-error-if-no-glob t + eshell-hist-ignoredups t + eshell-kill-on-exit t + eshell-prefer-lisp-functions t + eshell-prefer-lisp-variables t + eshell-scroll-to-bottom-on-input 'this + eshell-banner-message "" + eshell-hist-ignoredups 'erase + eshell-history-size 512 + eshell-input-filter (lambda (input) + (or (eshell-input-filter-default input) + (eshell-input-filter-initial-space input))) + eshell-prompt-function #'acdw/eshell-prompt) + (add-hook 'eshell-mode-hook + (defun eshell-setup () + (hungry-delete-mode -1) + (setq-local outline-regexp eshell-prompt-regexp + page-delimiter eshell-prompt-regexp + imenu-generic-expression + '(("Prompt" " $ \\(.*\\)" 1)) + truncate-lines t) + (setenv "PAGER" "cat")))) + +(use-package eat + :ensure t + :hook (eshell-load-hook . eat-eshell-mode)) + +(use-package exec-path-from-shell + :when (eq system-type 'gnu/linux) + :ensure t + :config + (add-to-list 'exec-path-from-shell-variables "SSH_AUTH_SOCK") + (add-to-list 'exec-path-from-shell-variables "SSH_AGENT_PID") + (add-to-list 'exec-path-from-shell-variables "GPG_AGENT_INFO") + (add-to-list 'exec-path-from-shell-variables "LANG") + (add-to-list 'exec-path-from-shell-variables "LC_CTYPE") + (add-to-list 'exec-path-from-shell-variables "XDG_CONFIG_HOME") + (add-to-list 'exec-path-from-shell-variables "XDG_CONFIG_DIRS") + (add-to-list 'exec-path-from-shell-variables "XDG_DATA_HOME") + (add-to-list 'exec-path-from-shell-variables "XDG_DATA_DIRS") + (add-to-list 'exec-path-from-shell-variables "XDG_CACHE_HOME") + (exec-path-from-shell-initialize)) + +(use-package eshell-bookmark + :ensure t + :hook (eshell-mode-hook . eshell-bookmark-setup)) + +(provide 'acdw-shell) +;;; acdw-shell.el ends here diff --git a/lisp/acdw-web.el b/lisp/acdw-web.el new file mode 100644 index 0000000..080cd9a --- /dev/null +++ b/lisp/acdw-web.el @@ -0,0 +1,28 @@ +;;; acdw.web.el --- Web browsing and such -*- lexical-binding: t; -*- + +;;; Code: + +(defcustom +browse-url-other-safe-browser-functions nil + "Other safe browser functions." + :type '(repeat function)) + +(defun +browse-url-browser-function-safe-p (f) + "Return t if F is a safe browser function." + (memq f (append +browse-url-other-safe-browser-functions + (mapcar (lambda (i) + (plist-get (cdr i) :value)) + (seq-filter (lambda (i) + (eq (car i) 'function-item)) + (cdr (get 'browse-url-browser-function + 'custom-type))))))) + + +;;; Packages + +(use-package browse-url + :config + (put 'browse-url-browser-function 'safe-local-variable + '+browse-url-browser-function-safe-p)) + +(provide 'acdw-web) +;;; acdw-web.el ends here -- cgit 1.4.1-21-gabe81