Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (26 sloc) 1.03 KB
;;; bash-to-eshell-aliases.el --- Summary:
;;; Commentary: Automates the conversion bash config aliases to a set of eshell aliases
;;; Code:
(defun read-lines (FILEPATH)
"Return a list of lines of a file at FILEPATH."
(with-temp-buffer
(insert-file-contents FILEPATH)
(split-string (buffer-string) "\n" t)))
(defun extract-bash-aliases (LIST)
"Takes a LIST of strings, and transforms it into a LIST of shell aliases."
(filter (lambda (element)
(and
(string-match-p (regexp-quote "alias") element)
(not (string-match-p (regexp-quote "#") element))))
LIST))
(defun skye/bash-to-eshell-aliases (BASHFILE)
"Takes a BASHFILE, trims it to a list of alias commands, and inserts them as eshell aliases."
(interactive "f")
(eshell)
(dolist (element (extract-bash-aliases (read-lines BASHFILE)))
(let ((trimmed (replace-regexp-in-string "=" " " element)))
(goto-char (point-max))
(insert trimmed)
(eshell-send-input))))
(provide 'bash-to-eshell-aliases)
;;; bash-to-eshell-aliases.el ends here