Complete Computing Environment: Shell Configuration

Table of Contents

(provide 'cce-shells)


There's not much here right now, since I'm not a huge user of the shell. Instead, I opt to wrap most repetitive things in Emacs commands. As such, I opt for a very light configuration over the top of bash to provide enough affordances to make it useful.

Bash Configuration Loader

It's possible for multiple CCE modules to push out Bash configurations, so each one tangles to its own file which is then executed as so:

- name: ~/.bash_profile assembled
  become: yes
  become_user: rrix
    src: out/bash_profile.d
    dest: ~/.bash_profile
    mode: 0755
    remote_src: False

- name: ~/.bashrc assembled
  become: yes
  become_user: rrix
    src: out/bashrc.d
    dest: ~/.bashrc
    mode: 0755
    remote_src: False
export PATH=~/bin/:$PATH
test -f /etc/bash_profile && . /etc/bash_profile

I am in San Francisco. This used to be a UTC setup, but it's really hard to make that work sanely, so I don't.

export TZ=America/Los_Angeles
export PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \[\033[00m\]\`if [ \$? == 0 ]; then echo \:\); else echo \:\(; fi\` "
test -f /etc/bashrc && . /etc/bashrc
export UBER_LDAP_UID=rrix
export EDITOR=emacsclient


Emacs has Shell Mode, a simple comint-mode backed shell that lets me do simple crap that don't need ncurses or anything like that. It uses bash and works sanely with pipelines, unlock eshell and doesn't eat my keybindings like ansi-term and term.

As of my latest Emacs update, shell-mode displays buffers in a new window when I do M-x shell which is almost always not what I want, instead opting for them to always appear in the same window as my cursor.

(add-to-list 'display-buffer-alist
             `(,(rx bos "*shell")

Use Emacs as pager

uhoreg has a cool script on Reddit which lets you use Emacs buffers as your pager.

t=$(tempfile -s .emacs-pager) || exit 1
cat - >> $t
echo 'reading into emacs...'
emacsclient "$t"
rm -f -- $t
export PAGER=emacs-pager
- name: emacs pager installed
    src: out/emacs-pager
    dest: /home/rrix/bin/emacs-pager
    mode: 0755

Author: Ryan Rix

Created: 2018-07-09 Mon 14:48

Validate XHTML 1.0