Hacker News new | ask | show | jobs
by selendym 549 days ago
In bash, you can do something like this out-of-the-box by setting the `PS1` variable to your liking. For example, I use the following in `/etc/bash.bashrc`:

  PROMPT_COMMAND='_prev_status="$?"'
  PS1='\n$(printf "%0${COLUMNS}d\n" 0 | tr 0 -)\n[\D{%y%m%d-%H%M%S}] \u@\H (${_prev_status})\n${PWD}\n\$ '
The first line saves the status of the previous command and the second line sets the prompt string. The result is something like this:

  ---------------------------------------- <these dashes span the terminal width>
  [date-time] user@host (status)
  /current/working/directory
  $ <next command>