complete-computing-environment/shell_vars.org

1.9 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)