2.8 KiB
Configuring Shell Variables
While Configuring Profile Variables concerns itself primarily with some basic configurations that goes in to ~/.bash_profile
, this document concerns itself with things that go in my ~/.bashrc
, things which are run by every new interactive bash shell process, rather than being run by the system once and inherited by sub-processes.
{ ... }:
{
programs.bash.enable = true;
I use Atuin for shell search history right now.
I cribbed my PS1
from Tor a long time ago, it is a simple on that simply puts a smiley-face if the previous command returned successfully, and a frown-face if the previous command returned an error-code.
home.sessionVariables = {
PS1 = ''\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \[\033[00m\]\`if [ \$? == 0 ]; then echo \:\); else echo \:\(; fi\` $ '';
};
}
That PS1
will prevent Emacs's command-interpreter ("comint") from working properly. One must set comint-prompt-regexp to make it behave properly:
(defun cce/fixup-comint ()
(interactive)
(setq-local comint-prompt-regexp "^[^#$%>)(\n]*[#$%>)(] +"))
(add-hook 'shell-mode-hook #'cce/fixup-comint)
(provide 'cce/shell-vars)
Eshell "smart" mode
(require 'em-smart)
(setq eshell-where-to-jump 'begin)
(setq eshell-review-quick-commands nil)
(setq eshell-smart-space-goes-to-end t)
(evil-define-key 'insert 'eshell-mode-map (kbd "M-a") #'eshell-bol)
(defun eshell/lcd (&optional directory)
(if (file-remote-p default-directory)
(with-parsed-tramp-file-name default-directory nil
(eshell/cd (tramp-make-tramp-file-name
(tramp-file-name-method v)
(tramp-file-name-user v)
nil
(tramp-file-name-host v)
nil
(or directory "")
(tramp-file-name-hop v))))
(eshell/cd directory)))
Eshell can now "emulate a terminal"
(use-package eat
:hook
(eshell-load . eat-eshell-mode)
(eshell-load . eat-eshell-visual-command-mode))