`LS_COLORS` is empty: a shell reached via `su -l` (root's, from the user)
loses foot's `COLORTERM`, and `dircolors` has no database entry for foot's
`TERM=foot`, which would otherwise leave `ls` uncolored.
+- `.profile.d/prompt.sh` — colored (bold) `[<date>/<time>/<zone>
+ user@host:path]$` `PS1`, with `PS2`/`PS3`/`PS4` matching. The `tput setaf`
+ color number is read from `~/.config/prompt_color_number` (see below),
+ falling back to `COLOR_DEFAULT` (7, white) if that's unreadable, so an
+ account without the file still gets a working prompt. Colors from `tput`;
+ `\D{...}`/`\u`/`\h`/`\w` instead of forked `date`/`pwd`. In bash the
+ colors are wrapped in `\[ \]` for readline's width counting, except `PS3`
+ (printed verbatim by `select`; bare codes). Helpers are `local`s of a
+ throwaway `_dot_profile_dot_prompt` function, unset after the call. Takes
+ effect because the loop line sits at the very end of `~/.profile`, after
+ Debian's stock one has sourced `~/.bashrc` (which sets its own `PS1`), so
+ this fragment gets the last word.
### `home/root/` and `home/user/`
Why: the `60-poweroff-on-failure.conf` drop-in only guards a hibernate
failure reached through systemd's own unit, not a direct
`systemctl hibernate`; `hibernate_safe` closes that gap.
+- `.config/prompt_color_number` (both, differing) — the prompt color read
+ by `prompt.sh`: 1 (red) for root, 2 (green) for the user. A plain data
+ file, so an account owner can swap the symlink for a file of their own,
+ which `link_home` then leaves alone.
### `home/user/` only
- `.profile.d/ssh-agent.sh` — starts `ssh-agent` and `ssh-add -q` once per
login, guarded by `[ -z "${SSH_AGENT_PID}" ]` (so e.g. a second `foot`
window doesn't start another). Root needs no agent.
-- `.profile.d/prompt.sh` — colored (bold, `COLOR_NUMBER`, default green)
- `[<date>/<time>/<zone> user@host:path]$` `PS1`, with `PS2`/`PS3`/`PS4`
- matching. Colors from `tput`; `\D{...}`/`\u`/`\h`/`\w` instead of forked
- `date`/`pwd`. In bash the colors are wrapped in `\[ \]` for readline's
- width counting, except `PS3` (printed verbatim by `select`; bare codes).
- Helpers are `local`s of a throwaway `_dot_profile_dot_prompt` function,
- unset after the call. Takes effect because the loop line sits at the very
- end of `~/.profile`, after Debian's stock one has sourced `~/.bashrc`
- (which sets its own `PS1`), so this fragment gets the last word.
- `.profile.d/kb.sh` — `kb` alias: `swaymsg 'input * xkb_switch_layout next'`.
- `.gitconfig` — minimal `[user]` section.
- `.config/foot/foot.ini` — `font=monospace:size=14.5` and
--- /dev/null
+_dot_profile_dot_prompt() {
+ local COLOR_NUMBER
+ local COLOR_ON
+ local COLOR_OFF
+ local COLOR_DEFAULT=7
+ local PATH_COLOR_NUMBER="${HOME}/.config/prompt_color_number"
+ # tput setaf numbers, e.g. 1 red, 2 green, 7 white
+ COLOR_NUMBER=$(cat "${PATH_COLOR_NUMBER}" 2>/dev/null) \
+ || COLOR_NUMBER="${COLOR_DEFAULT}"
+ COLOR_ON="$(tput setaf "${COLOR_NUMBER}" 2>/dev/null)"
+ COLOR_ON="${COLOR_ON}$(tput bold 2>/dev/null)"
+ COLOR_OFF="$(tput sgr0 2>/dev/null)"
+ # Bash confuses the line length when not told not to count escape
+ # sequences. PS3 is printed verbatim by "select", so it must get the
+ # unwrapped codes.
+ PS3="${COLOR_ON}select: ${COLOR_OFF}"
+ if [ -n "${BASH:-}" ]; then
+ COLOR_ON="\[${COLOR_ON}\]"
+ COLOR_OFF="\[${COLOR_OFF}\]"
+ fi
+ PS1="${COLOR_ON}[\D{%Y-%m-%d/%H:%M:%S/%Z} \u@\h:\w]\$ ${COLOR_OFF}"
+ PS2="${COLOR_ON}> ${COLOR_OFF}"
+ PS4="${COLOR_ON}+ ${COLOR_OFF}"
+}
+_dot_profile_dot_prompt
+unset -f _dot_profile_dot_prompt
+++ /dev/null
-_dot_profile_dot_prompt() {
- local COLOR_NUMBER=2
- local COLOR_ON
- local COLOR_OFF
- COLOR_ON="$(tput setaf "${COLOR_NUMBER}" 2>/dev/null)$(tput bold 2>/dev/null)"
- COLOR_OFF="$(tput sgr0 2>/dev/null)"
- # Bash confuses the line length when not told not to count escape
- # sequences. PS3 is printed verbatim by "select", so it must get the
- # unwrapped codes.
- PS3="${COLOR_ON}select: ${COLOR_OFF}"
- if [ -n "${BASH:-}" ]; then
- COLOR_ON="\[${COLOR_ON}\]"
- COLOR_OFF="\[${COLOR_OFF}\]"
- fi
- PS1="${COLOR_ON}[\D{%Y-%m-%d/%H:%M:%S/%Z} \u@\h:\w]\$ ${COLOR_OFF}"
- PS2="${COLOR_ON}> ${COLOR_OFF}"
- PS4="${COLOR_ON}+ ${COLOR_OFF}"
-}
-_dot_profile_dot_prompt
-unset -f _dot_profile_dot_prompt