my shell prompt

Published 2020-11-09, last edit 2020-11-15

A thread was recently promoted on nixers to show your shell prompt, so I’ll share some features of mine. I usually use bash with Emacs shell-mode, so I get vim bindings for free via evil, with the mode indicator being the cursor (’|’ vs ’█’). I usually use ’♥’ as a prompt character, but for the sake of this post I’ll use ’$’, as the heart can look wildly different depending on your font setup.

Errors and background processes:

$ false
! vim temp.txt
[1]+  Stopped                 vim temp.txt
$! true
$$ fg
vim temp

git stuff:

$ cd $(mktemp -d)
$ git init
Initialized empty Git repository in /tmp/tmp.enlQwywyEv/.git/
$ touch readme.md
? $ git checkout -b new_branch
Switched to a new branch 'new_branch'
(new_branch|?) $ git add readme.md
(new_branch|+) $ echo 'edit' >> readme.md
(new_branch|+*) $ git commit -m "initial"
[new_branch (root-commit) 3ff638e] initial
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 readme.md
(new_branch) $ git checkout -b master; git reset --hard
Switched to a new branch 'master'
HEAD is now at 3ff638e initial

non-standard environment detection (checks capital variables):

$ PYTHONPATH="$HOME/something/stateful"
E $ envv

ssh hostname:

$ ssh super.cool.vps
trouw $ logout

and a hack that tells Emacs where the shell is (including tramp information – this is normally used in the prompt, I’m just showing it out here):

$ ssh super.cool.vps
trouw $ tell_emacs_shell_location
trouw $ logout

Source is here: ~/.sh.d/style