Browse Source

Rudimentary email TUI + small updates for void

Simon Watson 3 years ago
parent
commit
1704342bcb
4 changed files with 96 additions and 14 deletions
  1. 4 3
      bashrc/bashrc-all
  2. 13 10
      emacs/.emacs-all
  3. 1 1
      emacs/linux-load/customs.el
  4. 78 0
      himalaya/himalaya_shell_ui.sh

+ 4 - 3
bashrc/bashrc-all

@@ -54,9 +54,10 @@ hnc() {
 	fi
 }
 
-# open submission in browser
-
-
+export HIMALAYA_PATH=$(which himalaya)
+if [ ! -z $HIMALAYA_PATH ]; then
+       . ~/Repos/dotfiles/himalaya/himalaya_shell_ui.sh
+fi
 # Case defines platform specific configs
 # Platform agnostic configs above
 case $(hostname) in

+ 13 - 10
emacs/.emacs-all

@@ -209,6 +209,11 @@
 (load "~/Repos/dotfiles/emacs/elisp/helpers.el")
 (global-set-key (kbd "C-c p") 'display-full-buffer-path)
 
+;; Disable bars
+(menu-bar-mode -1)
+(tool-bar-mode -1)
+(scroll-bar-mode -1)
+
 ;; Load for macOS
 ;;; Slime/etc
 (if (eq system-type 'darwin)
@@ -254,17 +259,15 @@
 	  (setq yas-snippet-dirs
 	    '("~/Repos/dotfiles/emacs/yasnippets/"))
 	  (yas-global-mode 1)
-
-	  (straight-use-package 'exwm)
-	  (require 'exwm)
-
-	  ;(require 'exwm-systemtray)
-	  ;(exwm-systemtray-enable)
-
-	  (load "~/Repos/dotfiles/emacs/linux-load/exwm-config.el")
+ 
+	  (if (file-exists-p "~/.enable_exwm")
+	      (progn
+		(straight-use-package 'exwm)
+		(require 'exwm)
+		(load "~/Repos/dotfiles/emacs/linux-load/exwm-config.el")
 	  
-	  (require 'exwm-config-spw)
-	  (exwm-config-spw)
+		(require 'exwm-config-spw)
+		(exwm-config-spw)))
 
 	  (setq visible-bell 1)
 	  (load "~/Repos/dotfiles/emacs/linux-load/customs.el")

+ 1 - 1
emacs/linux-load/customs.el

@@ -12,4 +12,4 @@
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
- '(default ((t (:family "Envy Code R" :foundry "UNKN" :slant normal :weight normal :height 83 :width normal)))))
+ '(default ((t (:family "Envy Code R" :foundry "UNKN" :slant normal :weight normal :height 120 :width normal)))))

+ 78 - 0
himalaya/himalaya_shell_ui.sh

@@ -0,0 +1,78 @@
+# Script to handle automating/interacting with himalaya email server
+
+# $BAT_PATH and $HIMALAYA_PATH are provided by .bashrc, where this
+# file is sourced from
+
+alias eml="$HIMALAYA_PATH list"  # List emails in default inbox
+alias ems="$HIMALAYA_PATH send"  # Provide email via stdin and send
+
+# Read email passed and page into bat/less
+function emr() {
+    READER="/bin/less"
+    if [ ! -z $BAT_PATH ]; then
+	READER=$BAT_PATH
+    fi
+    $HIMALAYA_PATH read $1 | $READER
+}
+
+# Generate template for new email reply and open in either emacs
+# or vim, depending on whether emacs server is running
+function emw() {
+    if [ -z $1 ]; then
+	echo "Must provide emw an emailID"
+	return 1
+    fi
+
+    EMAIL_FILE=$(mktemp)
+    $HIMALAYA_PATH template reply $1 > $EMAIL_FILE
+    email_file_editor $EMAIL_FILE
+    email_sender $EMAIL_FILE
+}
+
+# Generate template for a new email, as above
+function emn() {
+    EMAIL_FILE=$(mktemp)
+    
+    $HIMALAYA_PATH template new > $EMAIL_FILE
+    email_file_editor $EMAIL_FILE
+    email_sender $EMAIL_FILE
+
+}
+
+function email_file_editor() {
+    EMAIL_FILE=$1
+    
+    EMACS_SERVER_RUNNING=$(lsof -c emacs | grep server | wc -l)
+    if [ $EMACS_SERVER_RUNNING -gt 0 ]; then
+	emacsclient -c $EMAIL_FILE
+    else
+	$EDITOR $EMAIL_FILE
+    fi
+}
+
+function email_sender() {
+    EMAIL_FILE=$1
+    cat $EMAIL_FILE
+
+    echo -n "Do you want to send this email [y/n]: "
+    read USER_REPONSE
+
+    if [[ "$USER_REPONSE" == *"y"* ]]; then
+	echo "Sending email..."
+	cat -p $EMAIL_FILE | $HIMALAYA_PATH send
+	rm $EMAIL_FILE
+    else
+	echo "Aborting, email file at: $EMAIL_FILE"
+    fi   
+}
+
+function clean_old_emails() {
+    EMAILS_MATCHING=$(grep Content /tmp/tmp.* | cut -d ":" -f 1 | wc -l)
+    echo -n "Delete $EMAILS_MATCHING old emails: [y/n]: "
+    read USER_REPONSE
+    if [[ "$USER_REPONSE" == *"y"* ]]; then
+	for file in $(grep Content /tmp/tmp.* | cut -d ":" -f 1); do rm $file; done
+    else
+	echo "Not deleting..."
+    fi
+}