Pierre - thanks again, this is hugely helpful! I just wanted to add to this for everyone here, plus for (perhaps my own) future Google search reference:
In order to get KSH to evaluate the "id -R" each time I had to use single quotes. When using double-quotes id -R is evaluated only once, and then PS1 is set to 0 by default and stays that way. PS1=(rtable 0)... The single quotes preserves the literal $(id -R) and so it's being evaluated every single time the prompt is displayed. So in my .profile I have: export PS1='(rtable $(id -R)) [\u@\h]:\w\\$ ' Then if I switch rdomains using: "doas /sbin/route -T42 exec /bin/ksh" My prompt looks like: (rtable 42) [henry@openbsd]:~$ And for a bonus, here's a little script I put together that I use to easily switch between routing domains: https://gitlab.com/hbonath/openbsd-routing-context It simply runs a new elevated shell in the specified rtable e.g.: doas routing-table 42 would run a root shell in rtable 42. -Henry On Tue, Apr 2, 2019 at 5:07 PM Pierre Emeriaud <petrus.lt+open...@gmail.com> wrote: > Le mar. 2 avr. 2019 à 23:00, Henry Bonath <he...@thebonaths.com> a écrit : > > > > Hello, > > Does anyone have any suggestions as to how to add the current rtable to > the > > $PS1 prompt? > > > > I tend to flip back and forth between routing domains and tend to lose > track > > of which rdomain I am currently using. > > > > I've been attempting an approach by trying to run 'ps -aux -o rtable' > > and using some grep/cut-fu but I am not happy with the results. > > > > Perhaps there is something simpler that I am missing? > > Yes, `id -R` "Display the routing table of the current process": > > PS1="[\u@$\h:\w](rdomain$(id -R))\$ " >