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."
(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)
(string-match-p (regexp-quote "alias") element)
(not (string-match-p (regexp-quote "#") element))))
(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")
(dolist (element (extract-bash-aliases (read-lines BASHFILE)))
(let ((trimmed (replace-regexp-in-string "=" " " element)))
(goto-char (point-max))
(insert trimmed)
(provide 'bash-to-eshell-aliases)
;;; bash-to-eshell-aliases.el ends here